You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "jonahgao (via GitHub)" <gi...@apache.org> on 2024/09/20 10:38:32 UTC
[PR] Use qualified aliases to simplify searching DFSchema [datafusion]
jonahgao opened a new pull request, #12546:
URL: https://github.com/apache/datafusion/pull/12546
## Which issue does this PR close?
N/A.
## Rationale for this change
The following logic was introduced for `single_distinct_to_groupby` in #4050.
The reason was the lack of alias-with-qualifier, which caused the qualifier to be lost after alias. See [comment](https://github.com/apache/datafusion/pull/4050#discussion_r1011990524)
When searching for a qualified name in DFSchema, we must also check unqualified fields because they may have been aliased and previously had a qualifier. We can now use qualified aliases to avoid this.
https://github.com/apache/datafusion/blob/0243ebd585264852be55822e3504be54e1e0e406/datafusion/common/src/dfschema.rs#L358-L369
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
-->
## Are these changes tested?
By existing tests.
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
## Are there any user-facing changes?
No
<!--
If there are user-facing changes then we may require documentation to be updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api change` label.
-->
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Use qualified aliases to simplify searching DFSchema [datafusion]
Posted by "jonahgao (via GitHub)" <gi...@apache.org>.
jonahgao commented on code in PR #12546:
URL: https://github.com/apache/datafusion/pull/12546#discussion_r1768388191
##########
datafusion/sqllogictest/test_files/select.slt:
##########
@@ -1756,3 +1756,7 @@ SELECT "test.a" FROM (SELECT a AS "test.a" FROM test)
statement ok
DROP TABLE test;
+
+# Can't reference an unqualified column by a qualified name
+query error DataFusion error: Schema error: No field named t1\.v1\. Valid fields are "t1\.v1"\.
+SELECT t1.v1 FROM (SELECT 1 AS "t1.v1");
Review Comment:
This query will not produce an error on main branch, which is incorrect.
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Use qualified aliases to simplify searching DFSchema [datafusion]
Posted by "jonahgao (via GitHub)" <gi...@apache.org>.
jonahgao merged PR #12546:
URL: https://github.com/apache/datafusion/pull/12546
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] Use qualified aliases to simplify searching DFSchema [datafusion]
Posted by "jonahgao (via GitHub)" <gi...@apache.org>.
jonahgao commented on PR #12546:
URL: https://github.com/apache/datafusion/pull/12546#issuecomment-2367122964
Thanks @alamb for the review
--
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: github-unsubscribe@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org