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

Do not truncate while encoding values as varchar literal #10172

Merged
merged 1 commit into from
Dec 7, 2021

Conversation

kasiafi
Copy link
Member

@kasiafi kasiafi commented Dec 3, 2021

Related to #552

@cla-bot cla-bot bot added the cla-signed label Dec 3, 2021
Copy link
Member

@findepi findepi left a comment

Choose a reason for hiding this comment

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

last commit (Do not truncate while encoding values as varchar literal) LGTM.
i think it can go independently from the others

if (boundedLength > valueLength) {
return new Cast(stringLiteral, toSqlType(type), false, true);
}
throw new IllegalArgumentException(format("value %s does not fit in type %s", value.toStringUtf8(), varcharType));
Copy link
Member

Choose a reason for hiding this comment

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

value %s -> Value [%s]

Before this change, the LiteralEncoder truncated values which did
not fit in the expected varchar type.
This behavior led to silent correctness issue: certain cast
operators returned incorrect values (inconsistent with the declared
return type). The values were then adjusted by the LiteralEncoder
so that the query didn't fail.
Those cast operators are now fixed. Removing the truncating behavior
from the LiteralEncoder should expose any other existing issues
of this kind as well as prevent adding incorrect functions in the
future.
@kasiafi
Copy link
Member Author

kasiafi commented Dec 7, 2021

@findepi AC

@kasiafi kasiafi merged commit d3456a8 into trinodb:master Dec 7, 2021
@github-actions github-actions bot added this to the 366 milestone Dec 7, 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.

2 participants