forked from apache/doris
-
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.
fix element_at in old planner make fe exception and regress cases fro…
…m ck
- Loading branch information
Showing
3 changed files
with
207 additions
and
1 deletion.
There are no files selected for viewing
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
101 changes: 101 additions & 0 deletions
101
...ession-test/data/datatype_p0/nested_types/query/map_functions/test_basic_map_function.out
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,101 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !sql -- | ||
sum-map-value | ||
|
||
-- !sql -- | ||
1 1 4 6 0 | ||
2 1 2 3 0 | ||
|
||
-- !sql -- | ||
literal-array-map | ||
|
||
-- !sql -- | ||
2 [{"l":0.000000000000, "h":10000.000000000000, "t":0.100000000000}, {"l":10001.000000000000, "h":100000000000000.000000000000, "t":0.200000000000}] | ||
|
||
-- !sql -- | ||
10000.000000000000 0.100000000000 10001.000000000000 0.200000000000 | ||
|
||
-- !sql -- | ||
insert-into-select-literal | ||
|
||
-- !sql -- | ||
2020-01-01T00:00 {1234567898765432123456789:"c", -1234567898765432123456789:"d", -1:"a", 0:"b"} | ||
|
||
-- !sql -- | ||
a b c d | ||
|
||
-- !sql -- | ||
b a b | ||
|
||
-- !sql -- | ||
cast-literal | ||
|
||
-- !sql -- | ||
{"amory":26, "amory_up":34} | ||
|
||
-- !sql -- | ||
{"amory":26, "amory_up":34} | ||
|
||
-- !sql -- | ||
{"amory":[26, 34], "commiter":[2023, 2024]} | ||
|
||
-- !sql -- | ||
{"amory":[26, 34], "commiter":[2023, 2024]} | ||
|
||
-- !sql -- | ||
{"amory":{"in":2023}, "amory_up":{"commiter":2024}} | ||
|
||
-- !sql -- | ||
{"amory":{"in":2023}, "amory_up":{"commiter":2024}} | ||
|
||
-- !sql -- | ||
sum-map-value | ||
|
||
-- !nereid_sql -- | ||
1 1 4 6 0 | ||
2 1 2 3 0 | ||
|
||
-- !sql -- | ||
literal-array-map | ||
|
||
-- !nereid_sql -- | ||
1 [{"a":1.100000000000, "b":2.200000000000}, {"c":3.300000000000, "d":4.400000000000}] | ||
2 [{"l":0.000000000000, "h":10000.000000000000, "t":0.100000000000}, {"l":10001.000000000000, "h":100000000000000.000000000000, "t":0.200000000000}] | ||
|
||
-- !nereid_sql -- | ||
\N \N 10001.000000000000 0.200000000000 | ||
1.100000000000 2.200000000000 \N \N | ||
|
||
-- !sql -- | ||
insert-into-select-literal | ||
|
||
-- !nereid_sql -- | ||
2020-01-01T00:00 {-1:"a", 0:"b", 1234567898765432123456789:"c", -1234567898765432123456789:"d"} | ||
|
||
-- !nereid_sql -- | ||
a b c d | ||
|
||
-- !nereid_sql -- | ||
b a b | ||
|
||
-- !sql -- | ||
cast-literal | ||
|
||
-- !nereid_sql -- | ||
{"amory":26, "amory_up":34} | ||
|
||
-- !nereid_sql -- | ||
{"amory":26, "amory_up":34} | ||
|
||
-- !nereid_sql -- | ||
{"amory":[26, 34], "commiter":[2023, 2024]} | ||
|
||
-- !nereid_sql -- | ||
{"amory":[26, 34], "commiter":[2023, 2024]} | ||
|
||
-- !nereid_sql -- | ||
{"amory":{"in":2023}, "amory_up":{"commiter":2024}} | ||
|
||
-- !nereid_sql -- | ||
{"amory":{"in":2023}, "amory_up":{"commiter":2024}} | ||
|
104 changes: 104 additions & 0 deletions
104
...n-test/suites/datatype_p0/nested_types/query/map_functions/test_basic_map_function.groovy
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,104 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
suite("test_basic_map_function", "p0") { | ||
sql """ ADMIN SET FRONTEND CONFIG ('disable_nested_complex_type' = 'false'); """ | ||
sql """set enable_nereids_planner=false""" | ||
// ============ sum(map-value) ============ | ||
qt_sql """ SELECT "sum-map-value" """ | ||
sql """ DROP TABLE IF EXISTS t_map_amory;""" | ||
sql """ CREATE TABLE IF NOT EXISTS t_map_amory(id int(11), m Map<String, largeint>) ENGINE=OLAP DISTRIBUTED BY HASH(id) BUCKETS 1 PROPERTIES('replication_num' = '1');""" | ||
sql """ INSERT INTO t_map_amory VALUES(1, map("a", 1, "b", 2, "c", 3));""" | ||
sql """ INSERT INTO t_map_amory VALUES(1, map(concat("key",'a') , 1, "b", 2, "c", 3));""" | ||
sql """ INSERT INTO t_map_amory VALUES(2, map("a", 1, "b", 2, "c", 3));""" | ||
order_qt_sql """ SELECT id, sum(m['a']), sum(m['b']), sum(m['c']), sum(m['c'] = 0) FROM t_map_amory group by id order by id; """ | ||
|
||
// ============ literal array-map ============ | ||
qt_sql """ SELECT "literal-array-map" """ | ||
sql """ DROP TABLE IF EXISTS arr_nested_map_test_table;""" | ||
sql """ CREATE TABLE IF NOT EXISTS arr_nested_map_test_table (id int, arr array<map<string, decimal(28,12)>>) ENGINE=OLAP DISTRIBUTED BY HASH(id) BUCKETS 1 PROPERTIES('replication_num' = '1');""" | ||
// old planner can't support literal array-map "No matching function with signature" | ||
// sql """ INSERT INTO arr_nested_map_test_table VALUES(1, array(map("a", 1.1, "b", 2.2), map("c", 3.3, "d", 4.4)));""" | ||
sql """ INSERT INTO arr_nested_map_test_table VALUES(2, [{'l': 0.0, 'h': 10000.0, 't': 0.1}, {'l': 10001.0, 'h': 100000000000000.0, 't': 0.2}]);""" | ||
order_qt_sql """ SELECT * FROM arr_nested_map_test_table order by id ; """ | ||
order_qt_sql """ SELECT arr[1]['h'], arr[1]['t'], arr[2]['l'], arr[2]['t'] FROM arr_nested_map_test_table order by id ; """ | ||
|
||
// ============ insert into select literal ============ | ||
qt_sql """ SELECT "insert-into-select-literal" """ | ||
sql """ DROP TABLE IF EXISTS t_map_amory_1;""" | ||
sql """ CREATE TABLE IF NOT EXISTS t_map_amory_1(id datetime, m Map<largeint, String>) ENGINE=OLAP DISTRIBUTED BY HASH(id) BUCKETS 1 PROPERTIES('replication_num' = '1');""" | ||
// old planner will make type deduction error | ||
// sql """ INSERT INTO t_map_amory_1 SELECT '2020-01-01', map(-1, 'a', 0, 'b', cast('1234567898765432123456789' as largeint), 'c', cast('-1234567898765432123456789' as largeint), 'd');""" | ||
sql """ INSERT INTO t_map_amory_1 SELECT '2020-01-01', map(cast('1234567898765432123456789' as largeint), 'c', cast('-1234567898765432123456789' as largeint), 'd', -1, 'a', 0, 'b'); """ | ||
qt_sql """ SELECT * FROM t_map_amory_1; """ | ||
qt_sql """ SELECT m[-1], m[0], m[cast('1234567898765432123456789' as largeint)], m[cast('-1234567898765432123456789' as largeint)] FROM t_map_amory_1;""" | ||
qt_sql """ SELECT m[cast(0 as BIGINT)], m[cast(-1 as Largeint)], m[cast(0 as largeint)] FROM t_map_amory_1;""" | ||
|
||
// =================== cast literal =================== | ||
qt_sql """ SELECT "cast-literal" """ | ||
qt_sql """ SELECT CAST({'amory':26, 'amory_up':34} as Map<String, int>);""" | ||
qt_sql """ SELECT CAST('{\\'amory\\':26, \\'amory_up\\':34}' as Map<String, int>)""" | ||
qt_sql """ SELECT CAST({'amory':[26, 34], 'commiter':[2023, 2024]} as Map<String, Array<int>>)""" | ||
qt_sql """ SELECT CAST('{\\'amory\\':[26, 34], \\'commiter\\':[2023, 2024]}' as Map<String, Array<int>>)""" | ||
qt_sql """ SELECT CAST({'amory':{'in': 2023}, 'amory_up':{'commiter': 2024}} as Map<String, Map<String, int>>)""" | ||
qt_sql """ SELECT CAST('{\\'amory\\':{\\'in\\': 2023}, \\'amory_up\\':{\\'commiter\\': 2024}}' as Map<String, Map<String, int>>)""" | ||
|
||
|
||
// test in nereids planner | ||
sql """set enable_nereids_planner=true""" | ||
sql """ set enable_fallback_to_original_planner=false""" | ||
|
||
// ============ sum(map-value) ============ | ||
qt_sql """ SELECT "sum-map-value" """ | ||
sql """ DROP TABLE IF EXISTS t_map_amory;""" | ||
sql """ CREATE TABLE IF NOT EXISTS t_map_amory(id int(11), m Map<String, largeint>) ENGINE=OLAP DISTRIBUTED BY HASH(id) BUCKETS 1 PROPERTIES('replication_num' = '1');""" | ||
sql """ INSERT INTO t_map_amory VALUES(1, map("a", 1, "b", 2, "c", 3));""" | ||
sql """ INSERT INTO t_map_amory VALUES(1, map(concat("key",'a'), 1, "b", 2, "c", 3));""" | ||
sql """ INSERT INTO t_map_amory VALUES(2, map("a", 1, "b", 2, "c", 3));""" | ||
order_qt_nereid_sql """ SELECT id, sum(m['a']), sum(m['b']), sum(m['c']), sum(m['c'] = 0) FROM t_map_amory group by id order by id; """ | ||
|
||
// ============ literal array-map ============ | ||
qt_sql """ SELECT "literal-array-map" """ | ||
sql """ DROP TABLE IF EXISTS arr_nested_map_test_table;""" | ||
sql """ CREATE TABLE IF NOT EXISTS arr_nested_map_test_table (id int, arr array<map<string, decimal(28,12)>>) ENGINE=OLAP DISTRIBUTED BY HASH(id) BUCKETS 1 PROPERTIES('replication_num' = '1');""" | ||
sql """ INSERT INTO arr_nested_map_test_table VALUES(1, array(map("a", 1.1, "b", 2.2), map("c", 3.3, "d", 4.4)));""" | ||
sql """ INSERT INTO arr_nested_map_test_table VALUES(2, [{'l': 0.0, 'h': 10000.0, 't': 0.1}, {'l': 10001.0, 'h': 100000000000000.0, 't': 0.2}]);""" | ||
order_qt_nereid_sql """ SELECT * FROM arr_nested_map_test_table order by id ; """ | ||
order_qt_nereid_sql """ SELECT arr[1]['a'], arr[1]['b'], arr[2]['l'], arr[2]['t'] FROM arr_nested_map_test_table order by id ; """ | ||
|
||
// ============ insert into select literal ============ | ||
qt_sql """ SELECT "insert-into-select-literal" """ | ||
sql """ DROP TABLE IF EXISTS t_map_amory_1;""" | ||
sql """ CREATE TABLE IF NOT EXISTS t_map_amory_1(id datetime, m Map<largeint, String>) ENGINE=OLAP DISTRIBUTED BY HASH(id) BUCKETS 1 PROPERTIES('replication_num' = '1');""" | ||
sql """ INSERT INTO t_map_amory_1 SELECT '2020-01-01', map(-1, 'a', 0, 'b', cast('1234567898765432123456789' as largeint), 'c', cast('-1234567898765432123456789' as largeint), 'd');""" | ||
qt_nereid_sql """ SELECT * FROM t_map_amory_1; """ | ||
qt_nereid_sql """ SELECT m[-1], m[0], m[cast('1234567898765432123456789' as largeint)], m[cast('-1234567898765432123456789' as largeint)] FROM t_map_amory_1;""" | ||
qt_nereid_sql """ SELECT m[cast(0 as BIGINT)], m[cast(-1 as Largeint)], m[cast(0 as largeint)] FROM t_map_amory_1;""" | ||
|
||
// =================== cast literal =================== | ||
qt_sql """ SELECT "cast-literal" """ | ||
qt_nereid_sql """ SELECT CAST({'amory':26, 'amory_up':34} as Map<String, int>);""" | ||
qt_nereid_sql """ SELECT CAST('{\\'amory\\':26, \\'amory_up\\':34}' as Map<String, int>)""" | ||
qt_nereid_sql """ SELECT CAST({'amory':[26, 34], 'commiter':[2023, 2024]} as Map<String, Array<int>>)""" | ||
qt_nereid_sql """ SELECT CAST('{\\'amory\\':[26, 34], \\'commiter\\':[2023, 2024]}' as Map<String, Array<int>>)""" | ||
qt_nereid_sql """ SELECT CAST({'amory':{'in': 2023}, 'amory_up':{'commiter': 2024}} as Map<String, Map<String, int>>)""" | ||
qt_nereid_sql """ SELECT CAST('{\\'amory\\':{\\'in\\': 2023}, \\'amory_up\\':{\\'commiter\\': 2024}}' as Map<String, Map<String, int>>)""" | ||
|
||
|
||
|
||
|
||
} |