-
Notifications
You must be signed in to change notification settings - Fork 1
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
test/resources/acceptance/compound__cte_deadscope.analysis.edn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
;; If we decide to perform "dead scope" elimination, t1 would not be listed as a source either. | ||
{:tables [{:table "t1"} {:table "t2"}] | ||
:source-columns [{:table "t2", :column "x"} ;; from cte | ||
{:table "t2", :column "y"}] ;; from outer select | ||
|
||
;; See https://github.com/metabase/metabase/issues/42586 | ||
:overrides | ||
;; We are not taking into account the t1 (via cte) is not in-scope in the top-level SELECT. | ||
{:source-columns [{:column "x"} | ||
{:column "y"}]}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
WITH cte AS ( | ||
SELECT x FROM t1 | ||
) | ||
SELECT x, y FROM t2 |
12 changes: 12 additions & 0 deletions
12
test/resources/acceptance/compound__cte_nonambiguous.analysis.edn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{:tables [{:table "t1"} {:table "t2"}] | ||
:source-columns [{:table "t1", :column "x"} ;; from cte | ||
{:table "t2", :column "y"}] ;; from outer select | ||
|
||
;; See https://github.com/metabase/metabase/issues/42586 | ||
:overrides | ||
;; We are not taking into account that x is introduced with only t1 in scope. | ||
;; We are not taking into account that x must not be an ambiguous reference in | ||
;; 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"}]}} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
WITH cte AS ( | ||
SELECT x FROM t1 | ||
) | ||
SELECT x, y FROM t2 JOIN cte |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using links instead of just |
||
:overrides | ||
;; TODO We are missing some fields and some table qualifiers. | ||
{:source-columns [{:column "created_at"} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{:tables [{:table "t"}] | ||
:source-columns [{:table "t", :column "x"}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SELECT FALSE, 'str', 1, x FROM t |
2 changes: 2 additions & 0 deletions
2
test/resources/acceptance/literal__without_table.analysis.edn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{:tables [] | ||
:source-columns []} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SELECT FALSE, 'str', 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 botht1
andt2
, sincecte
is not referenced anywhere:There was a problem hiding this comment.
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.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.