forked from apache/gravitino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[apache#5573] Add test cases for decimal, array, map, row, format in …
…Trino CI for hive catalog (apache#5562) ### What changes were proposed in this pull request? 1. Add some cases for complex data type 2. Add some cases for different storage format ### Why are the changes needed? apache#5573 ### Does this PR introduce _any_ user-facing change? N/A ### How was this patch tested? Test locally.
- Loading branch information
1 parent
e0bce18
commit 5beaf0f
Showing
10 changed files
with
772 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
...ctor/integration-test/src/test/resources/trino-ci-testset/testsets/hive/00008_decimal.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
CREATE SCHEMA gt_hive.gt_decimal_db1; | ||
|
||
USE gt_hive.gt_decimal_db1; | ||
|
||
CREATE TABLE test_decimal_bounds (amount DECIMAL(10, 2)); | ||
|
||
INSERT INTO test_decimal_bounds VALUES (12345.67), (-9999999.99), (0.01); | ||
|
||
INSERT INTO test_decimal_bounds VALUES (123456789.00); -- Exceeds precision | ||
|
||
SELECT * FROM test_decimal_bounds; | ||
|
||
CREATE TABLE test_decimal_aggregation (value DECIMAL(12, 3)); | ||
|
||
INSERT INTO test_decimal_aggregation VALUES (1234.567), (8901.234), (567.890); | ||
|
||
SELECT SUM(value) FROM test_decimal_aggregation; | ||
|
||
SELECT AVG(value) FROM test_decimal_aggregation; | ||
|
||
CREATE TABLE test_decimal_arithmetic (val1 DECIMAL(5, 2), val2 DECIMAL(4, 1)); | ||
|
||
INSERT INTO test_decimal_arithmetic VALUES (123.45,10.1); | ||
|
||
SELECT val1 + val2 FROM test_decimal_arithmetic; | ||
|
||
SELECT val1 * val2 FROM test_decimal_arithmetic; | ||
|
||
SELECT val1 / val2 FROM test_decimal_arithmetic; | ||
|
||
CREATE TABLE test_decimal_max_min (max_min_val DECIMAL(18, 4)); | ||
|
||
INSERT INTO test_decimal_max_min VALUES (99999999999999.9999); | ||
|
||
INSERT INTO test_decimal_max_min VALUES (-99999999999999.9999); | ||
|
||
INSERT INTO test_decimal_max_min VALUES (100000000000000.0000); -- Exceeds max | ||
|
||
SELECT * FROM test_decimal_max_min ORDER BY max_min_val; | ||
|
||
CREATE TABLE test_decimal_nulls (nullable_val DECIMAL(8, 2)); | ||
|
||
INSERT INTO test_decimal_nulls VALUES (NULL), (123.45), (NULL); | ||
|
||
SELECT * FROM test_decimal_nulls; | ||
|
||
DROP TABLE gt_hive.gt_decimal_db1.test_decimal_bounds; | ||
|
||
DROP TABLE gt_hive.gt_decimal_db1.test_decimal_aggregation; | ||
|
||
DROP TABLE gt_hive.gt_decimal_db1.test_decimal_arithmetic; | ||
|
||
DROP TABLE gt_hive.gt_decimal_db1.test_decimal_max_min; | ||
|
||
DROP TABLE gt_hive.gt_decimal_db1.test_decimal_nulls; | ||
|
||
DROP SCHEMA gt_hive.gt_decimal_db1; |
62 changes: 62 additions & 0 deletions
62
...ctor/integration-test/src/test/resources/trino-ci-testset/testsets/hive/00008_decimal.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
CREATE SCHEMA | ||
|
||
USE | ||
|
||
CREATE TABLE | ||
|
||
INSERT: 3 rows | ||
|
||
<QUERY_FAILED> Cannot cast DECIMAL(11, 2) '123456789.00' to DECIMAL(10, 2) | ||
|
||
"12345.67" | ||
"-9999999.99" | ||
"0.01" | ||
|
||
CREATE TABLE | ||
|
||
INSERT: 3 rows | ||
|
||
"10703.691" | ||
|
||
"3567.897" | ||
|
||
CREATE TABLE | ||
|
||
INSERT: 1 row | ||
|
||
"133.55" | ||
|
||
"1246.845" | ||
|
||
"12.22" | ||
|
||
CREATE TABLE | ||
|
||
INSERT: 1 row | ||
|
||
INSERT: 1 row | ||
|
||
<QUERY_FAILED> Cannot cast DECIMAL(19, 4) '100000000000000.0000' to DECIMAL(18, 4) | ||
|
||
"-99999999999999.9999" | ||
"99999999999999.9999" | ||
|
||
CREATE TABLE | ||
|
||
INSERT: 3 rows | ||
|
||
"" | ||
"123.45" | ||
"" | ||
|
||
DROP TABLE | ||
|
||
DROP TABLE | ||
|
||
DROP TABLE | ||
|
||
DROP TABLE | ||
|
||
DROP TABLE | ||
|
||
DROP SCHEMA |
65 changes: 65 additions & 0 deletions
65
...nector/integration-test/src/test/resources/trino-ci-testset/testsets/hive/00009_array.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
CREATE SCHEMA gt_hive.gt_array_db1; | ||
|
||
USE gt_hive.gt_array_db1; | ||
|
||
CREATE TABLE test_array_basic (int_array ARRAY(INTEGER)); | ||
|
||
INSERT INTO test_array_basic VALUES (ARRAY[1, 2, 3]), (ARRAY[4, 5, NULL, 7]), (ARRAY[]); | ||
|
||
SELECT * FROM test_array_basic; | ||
|
||
SELECT int_array, CARDINALITY(int_array) AS array_length FROM test_array_basic; | ||
|
||
CREATE TABLE test_array_access (elements ARRAY(VARCHAR)); | ||
|
||
INSERT INTO test_array_access VALUES (ARRAY['apple', 'banana', 'cherry']); | ||
|
||
SELECT elements[1] AS first_element, elements[2] AS second_element FROM test_array_access; | ||
|
||
SELECT * FROM test_array_basic WHERE contains(int_array, 2); | ||
|
||
CREATE TABLE test_array_concat (array1 ARRAY(INTEGER), array2 ARRAY(INTEGER)); | ||
|
||
INSERT INTO test_array_concat VALUES (ARRAY[1, 2, 3], ARRAY[4, 5]); | ||
|
||
SELECT array1, array2, CONCAT(array1, array2) AS concatenated_array FROM test_array_concat; | ||
|
||
CREATE TABLE test_array_sort (unsorted_array ARRAY(INTEGER)); | ||
|
||
INSERT INTO test_array_sort VALUES (ARRAY[3, 1, 2]), (ARRAY[9, 7, 8]); | ||
|
||
SELECT unsorted_array, array_sort(unsorted_array) AS sorted_array FROM test_array_sort; | ||
|
||
CREATE TABLE test_array_nulls (mixed_array ARRAY(INTEGER)); | ||
|
||
INSERT INTO test_array_nulls VALUES (ARRAY[1, NULL, 3]), (ARRAY[NULL, NULL]); | ||
|
||
SELECT mixed_array, CARDINALITY(mixed_array) FROM test_array_nulls; | ||
|
||
CREATE TABLE test_array_agg (val INTEGER); | ||
|
||
INSERT INTO test_array_agg VALUES (1), (2), (3), (4); | ||
|
||
SELECT ARRAY_AGG(val) AS aggregated_array FROM test_array_agg; | ||
|
||
CREATE TABLE test_nested_array (nested_array ARRAY(ARRAY(VARCHAR))); | ||
|
||
INSERT INTO test_nested_array VALUES (ARRAY[ARRAY['a', 'b'], ARRAY['c', 'd']]); | ||
|
||
SELECT nested_array FROM test_nested_array; | ||
|
||
DROP TABLE gt_hive.gt_array_db1.test_array_basic; | ||
|
||
DROP TABLE gt_hive.gt_array_db1.test_array_access; | ||
|
||
DROP TABLE gt_hive.gt_array_db1.test_array_concat; | ||
|
||
DROP TABLE gt_hive.gt_array_db1.test_array_sort; | ||
|
||
DROP TABLE gt_hive.gt_array_db1.test_array_nulls; | ||
|
||
DROP TABLE gt_hive.gt_array_db1.test_array_agg; | ||
|
||
DROP TABLE gt_hive.gt_array_db1.test_nested_array; | ||
|
||
DROP SCHEMA gt_hive.gt_array_db1; |
71 changes: 71 additions & 0 deletions
71
...nector/integration-test/src/test/resources/trino-ci-testset/testsets/hive/00009_array.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
CREATE SCHEMA | ||
|
||
USE | ||
|
||
CREATE TABLE | ||
|
||
INSERT: 3 rows | ||
|
||
"[1, 2, 3]" | ||
"[4, 5, NULL, 7]" | ||
"[]" | ||
|
||
"[1, 2, 3]","3" | ||
"[4, 5, NULL, 7]","4" | ||
"[]","0" | ||
|
||
CREATE TABLE | ||
|
||
INSERT: 1 row | ||
|
||
"apple","banana" | ||
|
||
"[1, 2, 3]" | ||
|
||
CREATE TABLE | ||
|
||
INSERT: 1 row | ||
|
||
"[1, 2, 3]","[4, 5]","[1, 2, 3, 4, 5]" | ||
|
||
CREATE TABLE | ||
|
||
INSERT: 2 rows | ||
|
||
"[3, 1, 2]","[1, 2, 3]" | ||
"[9, 7, 8]","[7, 8, 9]" | ||
|
||
CREATE TABLE | ||
|
||
INSERT: 2 rows | ||
|
||
"[1, NULL, 3]","3" | ||
"[NULL, NULL]","2" | ||
|
||
CREATE TABLE | ||
|
||
INSERT: 4 rows | ||
|
||
"[1, 2, 3, 4]" | ||
|
||
CREATE TABLE | ||
|
||
INSERT: 1 row | ||
|
||
"[[a, b], [c, d]]" | ||
|
||
DROP TABLE | ||
|
||
DROP TABLE | ||
|
||
DROP TABLE | ||
|
||
DROP TABLE | ||
|
||
DROP TABLE | ||
|
||
DROP TABLE | ||
|
||
DROP TABLE | ||
|
||
DROP SCHEMA |
49 changes: 49 additions & 0 deletions
49
...onnector/integration-test/src/test/resources/trino-ci-testset/testsets/hive/00010_map.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
CREATE SCHEMA gt_hive.gt_map_db1; | ||
|
||
USE gt_hive.gt_map_db1; | ||
|
||
CREATE TABLE test_map_nulls (string_map MAP(VARCHAR, VARCHAR)); | ||
|
||
INSERT INTO test_map_nulls VALUES (MAP(ARRAY['key1'], ARRAY[NULL])); | ||
|
||
INSERT INTO test_map_nulls VALUES (MAP(ARRAY[NULL], ARRAY['value1'])); | ||
|
||
SELECT * FROM test_map_nulls; | ||
|
||
INSERT INTO test_map_nulls VALUES (MAP(ARRAY[], ARRAY[])); | ||
|
||
SELECT * FROM test_map_nulls ORDER BY cardinality(string_map); | ||
|
||
INSERT INTO test_map_nulls VALUES (MAP(ARRAY['dup', 'dup'], ARRAY['value1', 'value2'])); | ||
|
||
CREATE TABLE test_map_types (int_decimal_map MAP(INTEGER, DECIMAL(10, 2))); | ||
|
||
INSERT INTO test_map_types VALUES (MAP(ARRAY[1, 2147483647], ARRAY[12345.67, 99999.99])); | ||
|
||
SELECT * FROM test_map_types; | ||
|
||
INSERT INTO test_map_nulls VALUES (MAP(ARRAY['k1', 'k2', 'k3'], ARRAY['v1', 'v2', 'v3'])); | ||
|
||
SELECT element_at(string_map, 'k1') AS key1_value, element_at(string_map, 'k3') AS key3_value FROM test_map_nulls ORDER BY key1_value; | ||
|
||
CREATE TABLE test_map_complex (map_of_arrays MAP(VARCHAR, ARRAY(INTEGER))); | ||
|
||
INSERT INTO test_map_complex VALUES (MAP(ARRAY['a', 'b'], ARRAY[ARRAY[1, 2], ARRAY[3, 4, 5]])); | ||
|
||
SELECT * FROM test_map_complex; | ||
|
||
CREATE TABLE test_map_aggregation (map_data MAP(VARCHAR, INTEGER)); | ||
|
||
INSERT INTO test_map_aggregation VALUES (MAP(ARRAY['a', 'b'], ARRAY[1, 2])), (MAP(ARRAY['a', 'b'], ARRAY[3, 4])); | ||
|
||
SELECT map_data['a'] AS key_a, SUM(map_data['b']) AS sum_b FROM test_map_aggregation GROUP BY map_data['a'] ORDER BY key_a; | ||
|
||
DROP TABLE gt_hive.gt_map_db1.test_map_nulls; | ||
|
||
DROP TABLE gt_hive.gt_map_db1.test_map_types; | ||
|
||
DROP TABLE gt_hive.gt_map_db1.test_map_complex; | ||
|
||
DROP TABLE gt_hive.gt_map_db1.test_map_aggregation; | ||
|
||
DROP SCHEMA gt_hive.gt_map_db1; |
53 changes: 53 additions & 0 deletions
53
...onnector/integration-test/src/test/resources/trino-ci-testset/testsets/hive/00010_map.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
CREATE SCHEMA | ||
|
||
USE | ||
|
||
CREATE TABLE | ||
|
||
INSERT: 1 row | ||
|
||
<QUERY_FAILED> map key cannot be null | ||
|
||
"{key1=NULL}" | ||
|
||
INSERT: 1 row | ||
|
||
"{}" | ||
"{key1=NULL}" | ||
|
||
<QUERY_FAILED> Duplicate map keys (dup) are not allowed | ||
|
||
CREATE TABLE | ||
|
||
INSERT: 1 row | ||
|
||
"{2147483647=99999.99, 1=12345.67}" | ||
|
||
INSERT: 1 row | ||
|
||
"v1","v3" | ||
"","" | ||
"","" | ||
|
||
CREATE TABLE | ||
|
||
INSERT: 1 row | ||
|
||
"{a=[1, 2], b=[3, 4, 5]}" | ||
|
||
CREATE TABLE | ||
|
||
INSERT: 2 rows | ||
|
||
"1","2" | ||
"3","4" | ||
|
||
DROP TABLE | ||
|
||
DROP TABLE | ||
|
||
DROP TABLE | ||
|
||
DROP TABLE | ||
|
||
DROP SCHEMA |
Oops, something went wrong.