-
Notifications
You must be signed in to change notification settings - Fork 71
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 approx_count_distinct for queries without a FROM #524
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4eb1673
Fix approx_count_distinct for queries without a FROM
JelteF 6bbbbc3
Move to other spot for less hacky approach
JelteF d13489b
Improve comment
JelteF d465249
Remove useless argument
JelteF 495d832
Merge branch 'main' into fix-approx-count-distinct-without-rtable
JelteF 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,6 +123,13 @@ ContainsDuckdbItems(Node *node, void *context) { | |
} | ||
} | ||
|
||
if (IsA(node, Aggref)) { | ||
Aggref *func = castNode(Aggref, node); | ||
if (pgduckdb::IsDuckdbOnlyFunction(func->aggfnoid)) { | ||
return true; | ||
} | ||
} | ||
|
||
#if PG_VERSION_NUM >= 160000 | ||
return expression_tree_walker(node, ContainsDuckdbItems, context); | ||
#else | ||
|
@@ -160,10 +167,22 @@ IsAllowedStatement(Query *query, bool throw_error = false) { | |
} | ||
|
||
/* | ||
* If there's no rtable, we're only selecting constants. There's no point | ||
* in using DuckDB for that. | ||
* XXX: This is a bit of a weird one, because it is only allowed when | ||
* IsAllowedStatement is called with throw_error. | ||
* | ||
* If there's no rtable, we're only selecting constants. From a performance | ||
* perspective there's not really a point in using DuckDB. If we remove | ||
* this heck many common queries that are used to inspect postgres will | ||
* throw a warning or return incorrect results. For example: | ||
* | ||
* SELECT current_setting('work_mem'); | ||
* | ||
* So even if a user sets duckdb.force_execution = true, we still won't | ||
* forward such queries to DuckDB. With one exception: If the query | ||
* requires duckdb e.g. due to a duckdb-only function being used, we'll | ||
* still executing this in DuckDB. | ||
*/ | ||
if (!query->rtable) { | ||
if (!query->rtable && !throw_error) { | ||
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. This looks odd - if
|
||
elog(elevel, "DuckDB usage requires at least one table"); | ||
return false; | ||
} | ||
|
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
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.