Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

airframe-sql: Fix equi self-join #2819

Merged

Conversation

NicolasRichard
Copy link
Collaborator

Certain queries containing equi self-join cannot be parsed:

select A.name
from A
inner join (select name from A) t2 
on A.name = t2.name

The type resolver will end up throwing an exception, complaining about ambiguous column references. This is because the source code tries to match columns based on their source table. I guess it's to handle joins with unqualified attributes.

It took me a while to understand what the code was doing. I think that the matcher should not look at the source table name if a qualifier is present.

@github-actions github-actions bot added the bug label Apr 4, 2023
@codecov
Copy link

codecov bot commented Apr 4, 2023

Codecov Report

Merging #2819 (08920e4) into master (944fd01) will not change coverage.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2819   +/-   ##
=======================================
  Coverage   82.45%   82.45%           
=======================================
  Files         337      337           
  Lines       14273    14273           
  Branches     2312     2310    -2     
=======================================
  Hits        11769    11769           
  Misses       2504     2504           
Impacted Files Coverage Δ
...in/scala/wvlet/airframe/sql/model/Expression.scala 76.28% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 944fd01...08920e4. Read the comment docs.

Copy link
Member

@takezoe takezoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qualifiers were not considered. Makes sense!

@xerial xerial merged commit 705683b into wvlet:master Apr 6, 2023
@NicolasRichard NicolasRichard deleted the airframe-sql-fix-qualified-self-join branch April 11, 2023 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants