Skip to content

Fix query() function error message for PIVOT statements without explicit IN clauses#18900

Merged
Mytherin merged 1 commit into
duckdb:mainfrom
shivampr:query-function-pivot-error-message
Sep 11, 2025
Merged

Fix query() function error message for PIVOT statements without explicit IN clauses#18900
Mytherin merged 1 commit into
duckdb:mainfrom
shivampr:query-function-pivot-error-message

Conversation

@shivampr
Copy link
Copy Markdown
Contributor

@shivampr shivampr commented Sep 6, 2025

Description

Fixes bug where query() function showed confusing "Expected a single SELECT statement" error for PIVOT statements without explicit IN clauses, while PIVOT statements with explicit IN clauses worked correctly.

Fix: Enhanced ParseSubquery function to detect MultiStatement objects from PIVOT statements and provide clear error message.

Testing

  • Manual testing: Verified fix works in DuckDB CLI with both supported and unsupported PIVOT cases
  • Test coverage: Added unit tests covering positive and negative PIVOT scenarios
  • Regression testing: Confirmed existing query() functionality still works

Fixes: #18712

…cit IN clauses

    - query() function now provides helpful error message for PIVOT statements without explicit IN clauses
    - Previously showed confusing 'Expected a single SELECT statement' error, Now shows clear message: 'PIVOT statements without explicit IN clauses are not supported in query() function...'
    - PIVOT statements with explicit IN clauses continue to work correctly

    The issue occurred because PIVOT statements without explicit IN clauses create MultiStatement objects (containing CREATE TYPE + SELECT statements), but the query() function only accepted simple SelectStatement objects.

Fixes : duckdb#18712
@Mytherin Mytherin merged commit cc90b19 into duckdb:main Sep 11, 2025
53 checks passed
@Mytherin
Copy link
Copy Markdown
Collaborator

Thanks!

github-actions Bot pushed a commit to duckdb/duckdb-r that referenced this pull request Sep 11, 2025
Fix query() function error message for PIVOT statements without explicit IN clauses (duckdb/duckdb#18900)
Remove case-insensitive character from grammar files (duckdb/duckdb#18948)
github-actions Bot added a commit to duckdb/duckdb-r that referenced this pull request Sep 11, 2025
Fix query() function error message for PIVOT statements without explicit IN clauses (duckdb/duckdb#18900)
Remove case-insensitive character from grammar files (duckdb/duckdb#18948)

Co-authored-by: krlmlr <krlmlr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants