Why does the splitting of the two bigint type data in hive does not occur for integer division truncation, but occurs in presto
Presto mechanics:
Load data from various datasources via connectors
into Presto JVM. (Hive connector, Mysql connector, etc. see this)
Processing(scalar functions or aggregate functions) the data using Java
code.
Output the results from JVM (or disk if enable spill
).
In Java 1/2=0
therefore Presto will be the same. In Hive, I think because of UDF like overrive operator
: LanguageManual+UDF
To avoid truncation, just need to 'Thinking in Java':
int a = 1
int b = 2
c = 1.0*a/b
In Presto SQL
-- result: 0.3333333333333333
select cast(1 as double) / 3 from table_name
see: Migrating From Hive
It also can be done this way. select 1.0 * 1 / 3 from table_name Instead of casting the value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With