Skip to content
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

Fix failure when selecting a constant and all fields from row #10321

Merged
merged 1 commit into from Dec 17, 2021

Conversation

kasiafi
Copy link
Member

@kasiafi kasiafi commented Dec 16, 2021

Fixes #10298

In a query
SELECT 1, ROW(2, 3).*,
on the planning phase the expression Row(2, 3).* is unfolded
into subscript expressions: ROW(2, 3)[1] and ROW(2, 3)[2].
Because the query also contains the literal 1, the subscript
index in ROW(2, 3)[1] was rewritten into a symbol by the
TranslationMap. The resulting expression was ROW(2, 3)[s],
which was incorrect, since the row subscript is required to be
a constant.

This change modifies the TranslationMaps rewrite method
so that the subscript index is not rewritten.

@cla-bot cla-bot bot added the cla-signed label Dec 16, 2021
Comment on lines 321 to 322
// Do not rewrite subscript index into symbol. Index is required to be a literal.
return coerceIfNecessary(node, new SubscriptExpression(rewrittenBase, node.getIndex()));
Copy link
Member

Choose a reason for hiding this comment

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

Subscript must be literal for Row type, but subscript can be used with arrays and maps too.

In a query
`SELECT 1, ROW(2, 3).*`,
on the planning phase the expression `Row(2, 3).*` is unfolded
into subscript expressions: `ROW(2, 3)[1]` and `ROW(2, 3)[2]`.
Because the query also contains the literal `1`, the subscript
index in `ROW(2, 3)[1]` was rewritten into a symbol by the
`TranslationMap`. The resulting expression was `ROW(2, 3)[s]`,
which was incorrect, since the row subscript is required to be
a constant.

This change modifies the `TranslationMap`s rewrite method
so that the subscript index is not rewritten.
@martint martint merged commit 909a910 into trinodb:master Dec 17, 2021
@github-actions github-actions bot added this to the 367 milestone Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Strange behavior of all columns expression .*
3 participants