fix(sql): raise expression errors over constant derived tables - #321
Closed
EnRaiha wants to merge 6 commits into
Closed
fix(sql): raise expression errors over constant derived tables#321EnRaiha wants to merge 6 commits into
EnRaiha wants to merge 6 commits into
Conversation
…ng them Outer projections and aggregate/group-key arguments over a constant derived table used to fold silently: the CTE body materialized as bare value rows, the response shaper found no computed alias and emitted NULL, and aggregates over the body scanned an empty collection. Computed projection expressions now ride on the materialized-row scans as computed columns and evaluate per row (division raises 22012, sequence accessors raise 0A000); aggregates whose input is a non-Scan body lower it to a ProviderScan sub-plan so the accumulator receives the rows and evaluates its arguments and group keys against them. Window functions over a constant derived table are still folded silently; that path needs window evaluation in the row post-processor and is tracked separately.
… them per row The derived-table tail now transports window function specs from the outer query all the way to the materialized-row scan, which evaluates each spec per partition after computed columns. Partition, ordering, and argument errors fail the query instead of answering NULL. The subquery fold and validation walks now cover window expressions, so catalog casts inside window clauses fold and validate like every other expression on the wrapper.
inline_cte merges an outer SELECT's constraints onto a derived body when that body is itself a Scan, and it copied the BODY's (empty) window list in place of the OUTER's — so SUM/row_number/rank over FROM (SELECT * FROM c) silently answered NULL on every row. The outer window specs now run after the body's own, matching the post-processor branch, and two positive-value tests lock in the carriage and the results.
Remove '(issue #295 Gap 3)' references from four comment locations. Refine each comment to be professional and jargon-free while preserving the technical explanation of why window specs must be evaluated after computed columns over derived tables.
4 files still had stale (issue #295) references missed in previous cleanup pass — aggregate/plan.rs, set_ops.rs, provider_scan.rs, derived_expression_errors.rs module doc.
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.
Problem
Expression errors fold silently when the query's FROM source is a constant derived table (
FROM (SELECT 1 AS x) s). Division by zero returns NULL instead of raising22012.Fix
Three commits:
Test Results
Fixes #295