Skip to content

Commit

Permalink
[Fix](orc-reader) Fix orc decimal128 scale issue. (#25977)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaka11chen authored Oct 26, 2023
1 parent d9a3aa5 commit c86fad7
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion be/src/apache-orc
Original file line number Diff line number Diff line change
Expand Up @@ -1743,5 +1743,24 @@ LOCATION

msck repair table parquet_timestamp_nanos;

CREATE TABLE `orc_decimal_table`(
id INT,
decimal_col1 DECIMAL(8, 4),
decimal_col2 DECIMAL(18, 6),
decimal_col3 DECIMAL(38, 12),
decimal_col4 DECIMAL(9, 0),
decimal_col5 DECIMAL(27, 9),
decimal_col6 DECIMAL(9, 0))
ROW FORMAT SERDE
'org.apache.hadoop.hive.ql.io.orc.OrcSerde'
STORED AS INPUTFORMAT
'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat'
LOCATION
'/user/doris/preinstalled_data/orc_table/orc_decimal_table';

msck repair table orc_decimal_table;


show tables;
Binary file not shown.
18 changes: 18 additions & 0 deletions regression-test/data/external_table_p0/hive/test_hive_orc.out
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,24 @@ tablets tinyint_col 179 182 182 187 183 181 177 183 177 187 183 202 202 186 528
-- !only_partition_col --
3600 3600

-- !decimals1 --
1 1.1234 12.123456 123.123456789876 12 1234.123456789 123
2 1234.1234 123456789123.123456 12345678912345678912345678.123456789876 123456789 123456789123456789.123456780 987654321
3 1234.0000 123456789123.000000 12345678912345678912345678.000000000000 123456789 123456789123456789.000000000 987654321
4 0.0000 0.000000 123.123456789876 12 0E-9 123
5 1.1234 12.123456 0E-12 0 1234.123456789 0

-- !decimals2 --
3 1234.0000 123456789123.000000 12345678912345678912345678.000000000000 123456789 123456789123456789.000000000 987654321

-- !decimals3 --
1 1.1234 12.123456 123.123456789876 12 1234.123456789 123
2 1234.1234 123456789123.123456 12345678912345678912345678.123456789876 123456789 123456789123456789.123456780 987654321

-- !decimals4 --
4 0.0000 0.000000 123.123456789876 12 0E-9 123
5 1.1234 12.123456 0E-12 0 1234.123456789 0

-- !select_top50 --
4 55 999742610 400899305488827731 false 6.5976813E8 7.8723304616937395E17 \N base tennis pit vertical friday 2022-08-19T07:29:58 \N tablets smallint_col 2019-02-07 [7.53124931825377e+17] ["NbSSBtwzpxNSkkwga"] tablets smallint_col
2 49 999613702 105493714032727452 \N 6.3322381E8 9.8642324410240179E17 Unveil bright recruit participate. Suspect impression camera mathematical revelation. Fault live2 elbow debt west hydrogen current. how literary 2022-09-03T17:20:21 481707.1065 tablets boolean_col 2020-01-12 [] ["HoMrAnn", "wteEFvIwoZsVpVQdscMb", NULL, "zcGFmv", "kGEBBckbMtX", "hrEtCGFdPWZK"] tablets boolean_col
Expand Down
10 changes: 10 additions & 0 deletions regression-test/suites/external_table_p0/hive/test_hive_orc.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ suite("test_hive_orc", "all_types,p0,external,hive,external_docker,external_dock
qt_only_partition_col """select count(p1_col), count(p2_col) from orc_all_types;"""
}

// decimals
def decimals = {
qt_decimals1 """select * from orc_decimal_table order by id;"""
qt_decimals2 """select * from orc_decimal_table where id = 3 order by id;"""
qt_decimals3 """select * from orc_decimal_table where id < 3 order by id;"""
qt_decimals4 """select * from orc_decimal_table where id > 3 order by id;"""
}

String enabled = context.config.otherConfigs.get("enableHiveTest")
if (enabled != null && enabled.equalsIgnoreCase("true")) {
try {
Expand All @@ -86,6 +94,7 @@ suite("test_hive_orc", "all_types,p0,external,hive,external_docker,external_dock
search_in_int()
search_mix()
only_partition_col()
decimals()

sql """drop catalog if exists ${catalog_name}"""

Expand All @@ -103,3 +112,4 @@ suite("test_hive_orc", "all_types,p0,external,hive,external_docker,external_dock
}
}
}

0 comments on commit c86fad7

Please sign in to comment.