0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 CREATE TEMPORARY VIEW t AS SELECT 1.0 as a, 0.0 as b;
0019
0020
0021 select a / b from t;
0022 select a % b from t;
0023 select pmod(a, b) from t;
0024
0025
0026 create table decimals_test(id int, a decimal(38,18), b decimal(38,18)) using parquet;
0027
0028 insert into decimals_test values(1, 100.0, 999.0), (2, 12345.123, 12345.123),
0029 (3, 0.1234567891011, 1234.1), (4, 123456789123456789.0, 1.123456789123456789);
0030
0031
0032 select id, a+b, a-b, a*b, a/b from decimals_test order by id;
0033
0034
0035 select id, a*10, b/10 from decimals_test order by id;
0036
0037
0038 select 10.3 * 3.0;
0039 select 10.3000 * 3.0;
0040 select 10.30000 * 30.0;
0041 select 10.300000000000000000 * 3.000000000000000000;
0042 select 10.300000000000000000 * 3.0000000000000000000;
0043 select 2.35E10 * 1.0;
0044
0045
0046 select (5e36BD + 0.1) + 5e36BD;
0047 select (-4e36BD - 0.1) - 7e36BD;
0048 select 12345678901234567890.0 * 12345678901234567890.0;
0049 select 1e35BD / 0.1;
0050 select 1.2345678901234567890E30BD * 1.2345678901234567890E25BD;
0051
0052
0053 select 12345678912345678912345678912.1234567 + 9999999999999999999999999999999.12345;
0054 select 123456789123456789.1234567890 * 1.123456789123456789;
0055 select 12345678912345.123456789123 / 0.000000012345678;
0056
0057
0058 set spark.sql.decimalOperations.allowPrecisionLoss=false;
0059
0060
0061 select id, a+b, a-b, a*b, a/b from decimals_test order by id;
0062
0063
0064 select id, a*10, b/10 from decimals_test order by id;
0065
0066
0067 select 10.3 * 3.0;
0068 select 10.3000 * 3.0;
0069 select 10.30000 * 30.0;
0070 select 10.300000000000000000 * 3.000000000000000000;
0071 select 10.300000000000000000 * 3.0000000000000000000;
0072 select 2.35E10 * 1.0;
0073
0074
0075 select (5e36BD + 0.1) + 5e36BD;
0076 select (-4e36BD - 0.1) - 7e36BD;
0077 select 12345678901234567890.0 * 12345678901234567890.0;
0078 select 1e35BD / 0.1;
0079 select 1.2345678901234567890E30BD * 1.2345678901234567890E25BD;
0080
0081
0082 select 12345678912345678912345678912.1234567 + 9999999999999999999999999999999.12345;
0083 select 123456789123456789.1234567890 * 1.123456789123456789;
0084 select 12345678912345.123456789123 / 0.000000012345678;
0085
0086 drop table decimals_test;