-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Proper truncation missing in casts to varchar(x) #552
Comments
Some more context: prestodb/presto#7815 |
Is someone already working on this? I would like to give it a try... |
@findepi Does the work involve here involve just truncating the values in castToVarchar |
@ankitdixit each case needs to be looked at separately.
If you want to work on this, I would propose to raise a separate PR for each case being fixed. |
@findepi @dain @sopel39 trying to summarize from comments on prestodb/presto#7815, please let me know if this makes sense. Approach could be to add a 2 new session propertes
Behaviour:
We can also introduce another session property which can be used to chose notation type (conventional/scientific) |
@ankitdixit I don't have an opinion on this, so I'll let @martint and @findepi reply. |
why would this fail? |
@sopel39 from prestodb/presto#7815 (comment) |
@ankitdixit yes, but |
@sopel39 , I thought changing 1.0 to 1 would be losing precision in the generic sense as then 1.0 will cast as varchar(2) but 1.1 will fail. |
I think you can think of any floating point as having infinite number of trailing zeros. In this context you won't lose any precision. |
@ankitdixit, are you still planning to work on this? |
Is this #5015 a duplicate of this? |
@kasiafi are any known problems remaining? otherwise i'd close as done |
I'm pretty sure the bug still remains. I fixed the numeric types, and date type. We should go through all types that can be cast to varchar. They likely repeat the same wrong pattern. |
but ...
This is because https://github.com/prestosql/presto/blob/c74b775e103a7a239aafef1b7ca15fe6370495fe/presto-main/src/main/java/io/prestosql/type/BigintOperators.java#L270-L276
should consider
x
(@LiteralParameter("x") long x
) and truncate the result to make sure no more thanx
characters are returned.Same probably applies to casts from other types to varchar.
The text was updated successfully, but these errors were encountered: