mingmwang commented on code in PR #5593:
URL: https://github.com/apache/arrow-datafusion/pull/5593#discussion_r1140363032
##########
datafusion/sql/src/expr/identifier.rs:
##########
@@ -102,11 +138,32 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
ScalarValue::Utf8(Some(name)),
)))
} else {
- // table.column identifier
- Ok(Expr::Column(Column {
- relation: Some(relation),
- name,
- }))
+ let outer_query_schema_opt =
+ planner_context.outer_query_schema.clone();
+ if let Some(outer) = outer_query_schema_opt.as_ref() {
+ match outer.field_with_qualified_name(&relation,
&name) {
+ Ok(field) => {
+ // found an exact match on a qualified
name in the outer plan schema, so this is an outer reference column
+ Ok(Expr::OuterReferenceColumn(
+ field.data_type().clone(),
+ Column {
+ relation: Some(relation),
+ name,
+ },
+ ))
+ }
+ Err(_) => Ok(Expr::Column(Column {
+ relation: Some(relation),
+ name,
+ })),
+ }
+ } else {
+ // table.column identifier
+ Ok(Expr::Column(Column {
+ relation: Some(relation),
+ name,
+ }))
+ }
Review Comment:
Sure, will do.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]