Expr.map_key(key) turns the Python value into a literal with Expr._coerce, so an int always becomes i64 and a str always becomes string. The literal is built without regard to the key type of the map it indexes.
#294 makes infer_expression_type check the literal against the map's key type, which matches substrait-go's MapKeyRef.GetType. With that check in place, a lookup on a non-i64 integer-keyed map raises:
import substrait.dataframe as sub
from substrait.builders.type import map, i32, string, named_struct, struct
ns = named_struct(names=["m"], struct=struct(types=[map(i32(), string())], nullable=False))
sub.read_named_table("t", ns).select(sub.col("m").map_key(7).alias("v")).to_plan()
# ValueError: Map key literal type does not match map key type
On main the call doesn't raise, but the plan carries an i64 key literal for an i32 key, which substrait-go rejects. map_key should build the literal using the parent map's key type.
Measured on the #294 head at 77b2a02 (raises) and on main (no error; the reference is typed as map).
Expr.map_key(key)turns the Python value into a literal withExpr._coerce, so anintalways becomesi64and astralways becomesstring. The literal is built without regard to the key type of the map it indexes.#294 makes
infer_expression_typecheck the literal against the map's key type, which matches substrait-go'sMapKeyRef.GetType. With that check in place, a lookup on a non-i64integer-keyed map raises:On
mainthe call doesn't raise, but the plan carries ani64key literal for ani32key, which substrait-go rejects.map_keyshould build the literal using the parent map's key type.Measured on the #294 head at
77b2a02(raises) and onmain(no error; the reference is typed asmap).