Db2 fdw percentile push down#120
Merged
Merged
Conversation
… result-type crash foreign_expr_walker now recurses into Aggref.aggdirectargs (previously unwalked) and consults a shared db2AggregateInfo() helper so it only approves aggregates the deparser actually knows how to emit. deparseAggref gains deparseOrderedSetAggref() to build DB2's FUNC(fraction) WITHIN GROUP (ORDER BY col ASC|DESC) syntax for percentile_cont/percentile_disc, restricted to the single-column, non-array form DB2 supports. While testing this against the live DB2 instance, found that getUsedColumns() derived every pushed-down aggregate's result column type by borrowing its argument column's DB2 type. That's only correct when the aggregate preserves its input type (MIN/MAX, PERCENTILE_DISC); for AVG/SUM/PERCENTILE_CONT the output type differs, which crammed DB2's DECFLOAT-formatted result into a wrongly-typed, undersized buffer - crashing the backend on AVG(bigint_col) and producing a parse error for PERCENTILE_CONT. Now re-tags the result column with the aggregate's real return type when it differs from the borrowed argument type, routing it through the existing safe SQLGetData/text-fetch path. Verified against live DB2: PERCENTILE_CONT/PERCENTILE_DISC push down correctly (index-only scan), AVG(bigint) no longer crashes, and existing MIN/MAX/AVG/SUM/COUNT pushdown output is unchanged. Added real PERCENTILE_CONT/PERCENTILE_DISC assertions to tc015.sql and refreshed expected output. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
No description provided.