New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
opt: build IS OF (...) expression #31393
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you should open an issue for the bug?
Reviewed 5 of 5 files at r1.
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool thanks!
you can also mention in the commit message or comments that this is also done statically in postgres (transformAExprOf()
in src/backend/parser/parse_expr.c
)
pkg/sql/sem/tree/eval_test.go
Outdated
{`ARRAY['hello']::STRING[] IS OF (INT[])`, `false`}, | ||
{`3::INT2 IS OF (INT2)`, `true`}, | ||
|
||
// TODO(justin): these are currently incorrect. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can link the issue number in the comment
This commit builds expressions of the form x IS OF (...). This is an optbuilder-only change since the value of such an expression is always known at plan time. This is also performed statically in Postgres, in the file src/backend/parser/parse_expr.c in the function transformAExprOf. This commit also partially fixes a bug in the heuristic planner's implementation of this feature by using `Equivalent` instead of `FamilyEqual` to compare types, resulting in `INT[]` being considered distinct from `STRING[]`. It also exposes a bug that I think is difficult to fix at the moment, which is that the lack of a 1-1 mapping between datum and column types means the following is incorrectly reported as true: ``` 3::INT2 IS OF (INT4) ``` I've added relevant test cases and added a TODO for that case. Tagging @knz for the heuristic planner change and also to put the type-related bug on his radar. Release note (bug fix): Fixed IS OF (...) expressions to no longer report arrays with different element types as being the same.
TFTRs! bors r+ |
31393: opt: build IS OF (...) expression r=justinj a=justinj This commit builds expressions of the form x IS OF (...). This is an optbuilder-only change since the value of such an expression is always known at plan time. This commit also partially fixes a bug in the heuristic planner's implementation of this feature by using `Equivalent` instead of `FamilyEqual` to compare types, resulting in `INT[]` being considered distinct from `STRING[]`. It also exposes a bug that I think is difficult to fix at the moment, which is that the lack of a 1-1 mapping between datum and column types means the following is incorrectly reported as true: ``` 3::INT2 IS OF (INT4) ``` I've added relevant test cases and added a TODO for that case. Tagging @knz for the heuristic planner change and also to put the remaining type-related bug on his radar. Release note (bug fix): Fixed IS OF (...) expressions to no longer report arrays with different element types as being the same. Co-authored-by: Justin Jaffray <justin@cockroachlabs.com>
Build succeeded |
This commit builds expressions of the form x IS OF (...). This is an
optbuilder-only change since the value of such an expression is always
known at plan time.
This commit also partially fixes a bug in the heuristic planner's
implementation of this feature by using
Equivalent
instead ofFamilyEqual
to compare types, resulting inINT[]
being considereddistinct from
STRING[]
. It also exposes a bug that I think isdifficult to fix at the moment, which is that the lack of a 1-1 mapping
between datum and column types means the following is incorrectly
reported as true:
I've added relevant test cases and added a TODO for that case.
Tagging @knz for the heuristic planner change and also to put the
remaining type-related bug on his radar.
Release note (bug fix): Fixed IS OF (...) expressions to no longer
report arrays with different element types as being the same.