feat(annotate_types): annotate ranking window functions with constant return types [CLAUDE]#7651
Closed
RichardHughes-amp wants to merge 7 commits into
Closed
feat(annotate_types): annotate ranking window functions with constant return types [CLAUDE]#7651RichardHughes-amp wants to merge 7 commits into
RichardHughes-amp wants to merge 7 commits into
Conversation
…type propagation IGNORE NULLS and RESPECT NULLS wrappers should propagate their inner expression's type, but the TypeAnnotator has no handler for them so they return UNKNOWN even when the inner expression is correctly typed. [CLAUDE] Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…wrappers Introduce NullTreatment as a common base class for IgnoreNulls and RespectNulls, then include it alongside Unary/Alias in the unary annotator registration. Both wrappers carry a single `this` child and never change the expression's type — only its null-handling behaviour — so propagating `.this.type` is the correct semantic. [CLAUDE] Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
… return types RANK, DENSE_RANK, ROW_NUMBER, NTILE → BIGINT PERCENT_RANK, CUME_DIST → DOUBLE Registered in base EXPRESSION_METADATA so the annotation applies across all dialects rather than requiring per-dialect overrides. [CLAUDE]
Collaborator
|
Hello @RichardHughes-amp thanks for the pr. Did you check Databricks and confirm that it returns |
Contributor
Author
You're correct, it does return that, and I did check that. I thought that BIGINT was 'close enough'. I'll refine. |
…ive/Spark/Databricks [CLAUDE]
…nowflake [CLAUDE]
…s 9 more dialects [CLAUDE]
Contributor
Author
|
Replacing this with #7658. |
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 window functions
DenseRank,Ntile,Rank, andRowNumberare always BIGINT.The window functions
CumeDistandPercentRankare always DOUBLE.I checked eight dialects - PostgreSQL, SQL Server, Databricks, Snowflake, BigQuery, Trino, ClickHouse, and Oracle - to verify this was correct. It approximately was. Three exceptions:
annotate_functions.sqltest, and it renders asNullable(UInt64); I'm leery of implementing it.I'm relatively certain these deviations from BIGINT and DOUBLE can be ignored.