You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem or challenge?
After #10995, we have parse_sql_expr() to create a logical expression from the SQL string. This API allows creating the expression with a Schema. I tried to create the expression with a qualified schema:
let sql = "a < 5 OR a = 8";let expr = col("t.a").lt(lit(5_i64)).or(col("t.a").eq(lit(8_i64)));// provide type information that `a` is an Int32let schema = Schema::new(vec![Field::new("a",DataType::Int32,true)]);let df_schema = DFSchema::try_from_qualified_schema("t",&schema).unwrap();let ctx = SessionContext::new();let parsed_expr = ctx.parse_sql_expr(sql,&df_schema)?;assert_eq!(parsed_expr, expr);
I expected the identifier to be col("t.a"), but it is actually col("a").
I think the behavior can be aligned with the planning for the SQL statement:
ctx.register_batch("t",a_batch());let df = ctx.sql("SELECT a < 5 OR a = 8 FROM t").await?.into_optimized_plan()?;dbg!(&df);
The result would be:
[datafusion-examples/examples/parse_sql_expr.rs:89:5] &df = Projection: t.a < Int32(5) OR t.a = Int32(8) AS t.a < Int64(5) OR t.a = Int64(8)
TableScan: t projection=[a]
All of the identifiers are qualified.
Describe the solution you'd like
I think we can find the field by qualified_field_with_unqualified_name, and pass the qualifier when planning a column at
Is your feature request related to a problem or challenge?
After #10995, we have
parse_sql_expr()
to create a logical expression from the SQL string. This API allows creating the expression with aSchema
. I tried to create the expression with a qualified schema:I expected the identifier to be
col("t.a")
, but it is actuallycol("a")
.I think the behavior can be aligned with the planning for the SQL statement:
The result would be:
All of the identifiers are qualified.
Describe the solution you'd like
I think we can find the field by
qualified_field_with_unqualified_name
, and pass the qualifier when planning a column atdatafusion/datafusion/sql/src/expr/identifier.rs
Lines 50 to 57 in 28fa74b
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: