Skip to content

Conversation

@geooo109
Copy link
Collaborator

@geooo109 geooo109 commented Dec 5, 2025

This PR adds type annotation for bq NULL

SELECT typeof(NULL);
> INT64

exp.LaxInt64,
exp.Length,
exp.Ntile,
exp.Null,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this affect coercion? e.g.

select whatever_expr union all select null

I think the type should always coerce to whatever_expr here.

Copy link
Collaborator Author

@geooo109 geooo109 Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you wrap it in a CTE, it works fine.

The UNION ALL expression isn't annotated as is (the expression has unknown type).

We handle the coercion of Set Operations in the annotate_scope, when we have sources (it was added mostly for CTES).

In queries like this select whatever_expr union all select null, we don't apply any coercion between the LHS/RHS. There are cases that make this tricky:

D with tbl as (select 1::INT as a, a+1 as b union all select 1::float as a, NULL as b) select typeof(a), typeof(b) from tbl;
┌───────────┬───────────┐
│ typeof(a) │ typeof(b) │
│  varchar  │  varchar  │
├───────────┼───────────┤
│ FLOAT     │ INTEGER   │
│ FLOAT     │ INTEGER   │
└───────────┴───────────┘

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.

3 participants