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

Fix phantom fields for boolean literals #84

Merged
merged 4 commits into from
Aug 16, 2024
Merged

Conversation

crisptrutski
Copy link
Collaborator

Pretty straight forward. Also adds a failing test with override for CTEs.

Copy link
Contributor

@piranha piranha left a comment

Choose a reason for hiding this comment

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

I guess I can approve seems this doesn't seem a regression, do we need to track that as a separate issue?

;; the top-level query.
{:source-columns [{:column "x"}
;; We are not excluding the CTE, whose outputs are known, as a source for y.
{:column "y"}]}}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the result here is incorrect, because x is from both t1 and t2, since cte is not referenced anywhere:

testmetabase=# with cte as (select id from core_user limit 1) select id, name from report_card limit 2;
 id |              name              
----+--------------------------------
  2 | Orders with People
  1 | Aerodynamic Copper Knife trend
(2 rows)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Whoops, I meant for cte to be in scope.

mysql > with cte as (select id from core_user limit 1)
        select id name from report_card join cte limit 2;

ERROR 1052 (23000): Column 'id' in field list is ambiguous

Since Macaw is garbage-in-garbage-out for invalid queries, I think the correct conclusion is that id come from core_user only.

As for the actual query I wrote here, I guess you're right that in the short term returning both qualifications makes the most sense. One could imagine it doing some "dead scope analysis" however and excluding both the table and fields for the unused CTE.

@crisptrutski
Copy link
Collaborator Author

I guess I can approve seems this doesn't seem a regression, do we need to track that as a separate issue?

I see all the CTE and subselect defects being nested under metabase/metabase#42586

Hmm, going to start adding ticket references to each :override for good measure.

@@ -4,6 +4,7 @@
{:table "report_dashboardcard", :column "card_id"}
{:table "report_dashboardcard", :column "created_at"}] ;; from outer select

;; See https://github.com/metabase/metabase/issues/42586
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Using links instead of just #1212312 to disambiguate whether it's tracked in metabase or macaw.

@crisptrutski crisptrutski enabled auto-merge (squash) August 16, 2024 11:40
@crisptrutski crisptrutski merged commit 1c4ea0b into master Aug 16, 2024
4 checks passed
@crisptrutski crisptrutski deleted the fix-literals branch August 16, 2024 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants