You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2020/12/14 08:56:58 UTC

[GitHub] [hive] zabetak opened a new pull request #1771: HIVE-24528: Wrong implicit type conversion when comparing decimals and strings

zabetak opened a new pull request #1771:
URL: https://github.com/apache/hive/pull/1771


   ### What changes were proposed in this pull request?
   Convert to decimal (instead of double) when comparing decimals and strings.
   
   ### Why are the changes needed?
   Fix unexpected (by some considered wrong) query results and handle better precision loss (examples in HIVE-24528)
   
   ### Does this PR introduce _any_ user-facing change?
   Yes, this is a breaking change and query results when comparing decimals and strings may change. 
   
   ### How was this patch tested?
   `mvn test -Dtest=TestMiniLlapLocalCliDriver -Dqfile="dec_str.q"`


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] wangyum commented on pull request #1771: HIVE-24528: Wrong implicit type conversion when comparing decimals and strings

Posted by GitBox <gi...@apache.org>.
wangyum commented on pull request #1771:
URL: https://github.com/apache/hive/pull/1771#issuecomment-744440947


   What if the string is a very large number that exceeds the max decimal precision?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] wangyum commented on pull request #1771: HIVE-24528: Wrong implicit type conversion when comparing decimals and strings

Posted by GitBox <gi...@apache.org>.
wangyum commented on pull request #1771:
URL: https://github.com/apache/hive/pull/1771#issuecomment-744470603


   
   Type | Disadvantage
   -- | --
   Decimal | Can not correct compare if the string is a very large number that exceeds   the max decimal precision. E.g.   `cast('1234567890123456789012345678901234567890' as decimal(38, 0)) >   cast(1 as decimal(18, 0))`
   String | Can not correct compare if trailing zeros . E.g. `'1.10' = cast(1.1 as   string)`
   Double | Can not correct compare if exceeds double precision. E.g.   `cast('1234567890123456789012345678901234567890' as double) <   cast('1234567890123456789012345678901234567891' as double)`
   
   How about throwing exceptions like PostgreSQL?
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] zabetak commented on pull request #1771: HIVE-24528: Wrong implicit type conversion when comparing decimals and strings

Posted by GitBox <gi...@apache.org>.
zabetak commented on pull request #1771:
URL: https://github.com/apache/hive/pull/1771#issuecomment-744450241


   > What if the string is a very large number that exceeds the max decimal precision?
   
   Other kind of unexpected behavior but maybe better documented. Citing the [wiki](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types): _After such a type change, if the data can be shown correctly with the new type, the data will be displayed. Otherwise, the data will be displayed as NULL_ 
   
   I haven't made entirely my mind if its better to keep double or go for decimal but raised a PR to kick-off some discussion and see also the impact on the code base.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] zabetak commented on pull request #1771: HIVE-24528: Wrong implicit type conversion when comparing decimals and strings

Posted by GitBox <gi...@apache.org>.
zabetak commented on pull request #1771:
URL: https://github.com/apache/hive/pull/1771#issuecomment-744723867


   @wangyum have a look on https://github.com/apache/hive/pull/1780 for type safety checks.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] zabetak commented on pull request #1771: HIVE-24528: Wrong implicit type conversion when comparing decimals and strings

Posted by GitBox <gi...@apache.org>.
zabetak commented on pull request #1771:
URL: https://github.com/apache/hive/pull/1771#issuecomment-744475557


   > How about throwing exceptions like PostgreSQL?
   
   There is Postgres, and there is also MySQL, MSSQL, Oracle, and many others who act differently as I mentioned in the JIRA.
   
   I agree with the exception and looking to it right now but most likely it will be configurable behind the `hive.strict.checks.type.safety` property (or another similar one). So it still remains the question what happens when we don't throw. 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] github-actions[bot] closed pull request #1771: HIVE-24528: Wrong implicit type conversion when comparing decimals and strings

Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed pull request #1771:
URL: https://github.com/apache/hive/pull/1771


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] github-actions[bot] commented on pull request #1771: HIVE-24528: Wrong implicit type conversion when comparing decimals and strings

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #1771:
URL: https://github.com/apache/hive/pull/1771#issuecomment-778531491


   This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
   Feel free to reach out on the dev@hive.apache.org list if the patch is in need of reviews.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org