buraksenn commented on code in PR #20720:
URL: https://github.com/apache/datafusion/pull/20720#discussion_r3093783598
##########
datafusion/sql/src/select.rs:
##########
@@ -690,21 +694,75 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
self.plan_table_with_joins(input, planner_context)
}
_ => {
+ let extract_table_name =
+ |t: &TableWithJoins| -> Option<(String, Option<Span>)> {
+ match &t.relation {
+ TableFactor::Table { alias: Some(a), .. }
+ | TableFactor::Derived { alias: Some(a), .. }
+ | TableFactor::Function { alias: Some(a), .. }
+ | TableFactor::UNNEST { alias: Some(a), .. }
+ | TableFactor::NestedJoin { alias: Some(a), .. }
=> {
+ let span =
Span::try_from_sqlparser_span(a.name.span);
+ let name =
+
self.ident_normalizer.normalize(a.name.clone());
+ Some((name, span))
+ }
+ TableFactor::Table {
+ name, alias: None, ..
+ } => {
+ let span =
+
Span::try_from_sqlparser_span(t.relation.span());
+ let table_name = name
+ .0
+ .iter()
+ .filter_map(|p| p.as_ident())
+ .map(|id|
self.ident_normalizer.normalize(id.clone()))
+ .next_back()?;
+ Some((table_name, span))
+ }
+ _ => None,
+ }
+ };
+
+ let mut alias_spans: HashMap<String, Option<Span>> =
HashMap::new();
Review Comment:
I've missed this actually and added test case and properly use
TableReferences
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]