Fix presto_unnest() CTE handling and mark as experimental#313
Merged
jarodmeng merged 1 commit intoprestodb:masterfrom Nov 10, 2025
Merged
Fix presto_unnest() CTE handling and mark as experimental#313jarodmeng merged 1 commit intoprestodb:masterfrom
jarodmeng merged 1 commit intoprestodb:masterfrom
Conversation
- Fix SQL generation to not wrap simple table/CTE names in parentheses when presto_unnest() is called on a CTE. This was causing CTE detection to fail in nested CTE scenarios. - Mark presto_unnest() as experimental using lifecycle badge due to recent bug reports and fixes. - Add test case for operation -> CTE -> presto_unnest -> CTE scenario to ensure the fix is covered by the test suite.
Reviewer's GuideThis PR refines the SQL rendering in presto_unnest to skip wrapping simple table/CTE names, annotates presto_unnest() as experimental, and adds a targeted test for an operation→CTE→presto_unnest→CTE workflow. Sequence diagram for SQL rendering in presto_unnest() with CTE handlingsequenceDiagram
participant Caller
participant presto_unnest
participant sql_render_unnest_query
participant dbplyr_build_sql
Caller->>presto_unnest: Call with table or CTE
presto_unnest->>sql_render_unnest_query: Render SQL
sql_render_unnest_query->>dbplyr_build_sql: If input starts with SELECT (complex subquery)
dbplyr_build_sql-->>sql_render_unnest_query: Return SQL with parentheses
sql_render_unnest_query->>dbplyr_build_sql: If input is simple table/CTE name
dbplyr_build_sql-->>sql_render_unnest_query: Return SQL without parentheses
sql_render_unnest_query-->>presto_unnest: Return final SQL
presto_unnest-->>Caller: Return result
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- The string-based check for wrapping subqueries (looking for a leading “SELECT”) may misclassify more complex query sources—consider using dbplyr’s query AST to robustly distinguish simple table/CTE names from subqueries.
- I didn’t see an importFrom(lifecycle, badge) entry in the NAMESPACE diff—double-check that the lifecycle badge is actually imported so the experimental tag renders correctly.
- The new CTE integration test has a lot of setup/teardown boilerplate—consider extracting common connection and CTE management into a helper to reduce duplication and improve readability.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The string-based check for wrapping subqueries (looking for a leading “SELECT”) may misclassify more complex query sources—consider using dbplyr’s query AST to robustly distinguish simple table/CTE names from subqueries.
- I didn’t see an importFrom(lifecycle, badge) entry in the NAMESPACE diff—double-check that the lifecycle badge is actually imported so the experimental tag renders correctly.
- The new CTE integration test has a lot of setup/teardown boilerplate—consider extracting common connection and CTE management into a helper to reduce duplication and improve readability.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The debugging was mainly done by the package author, but the fix is implemented by the Cursor AI.