forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix](default value) enable HLL_EMPTY_DEFAULT_VALUE (apache#34447)
The goal of this pr is to make it possible to use `HLL_EMPTY()` to fill missing hll column. As shown in `test_default_hll.groovy`, if we don't specify hll column, it will use HLL_EMPTY to fill it. https://github.com/apache/doris/blob/f180d90bb8db1af8bee43e095de55cfe72e95ecc/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java#L362-L367 Existing analysis will add HLL_EMPTY_DEFAULT_VALUE as default value for hll column, but some relative problem would occurs if we didn't pass `hll_hash(x)` ... for this column. This pr add `defaultValueExprDef` for HLL_EMPTY_DEFAULT_VALUE (whick is used in streamload mode) and make default hll column pass the analysis for `NativeInsertStmt` and `Load`.
- Loading branch information
1 parent
813a697
commit 6b50368
Showing
9 changed files
with
147 additions
and
5 deletions.
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
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
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
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
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
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
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,29 @@ | ||
-- This file is automatically generated. You should know what you did if you want to edit this | ||
-- !insert_into1 -- | ||
0 | ||
0 | ||
0 | ||
0 | ||
|
||
-- !stream_load_csv1 -- | ||
0 | ||
0 | ||
0 | ||
0 | ||
1 | ||
1 | ||
|
||
-- !select_1 -- | ||
0 | ||
0 | ||
0 | ||
0 | ||
|
||
-- !stream_load_csv1 -- | ||
0 | ||
0 | ||
0 | ||
0 | ||
0 | ||
0 | ||
|
2 changes: 2 additions & 0 deletions
2
regression-test/data/correctness_p0/test_default_hll_streamload.csv
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,2 @@ | ||
5,5 | ||
6,6 |
99 changes: 99 additions & 0 deletions
99
regression-test/suites/correctness_p0/test_default_hll.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,99 @@ | ||
// 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_default_hll") { | ||
def tableName = "test_default_hll" | ||
|
||
sql """ DROP TABLE IF EXISTS ${tableName} """ | ||
sql """ | ||
CREATE TABLE IF NOT EXISTS ${tableName} | ||
( | ||
k TINYINT, | ||
v1 DECIMAL(10, 2) DEFAULT "0", | ||
h1 hll NOT NULL COMMENT "hll column" | ||
) | ||
UNIQUE KEY(K) | ||
DISTRIBUTED BY HASH(k) | ||
PROPERTIES("replication_num" = "1"); | ||
""" | ||
|
||
// test insert into. | ||
sql " insert into ${tableName} (k, v1, h1) values (1, 1, hll_empty()); " | ||
sql " insert into ${tableName} (k, v1, h1) values (2, 2, hll_empty()); " | ||
sql " insert into ${tableName} (k, v1, h1) values (3, 3, hll_empty()); " | ||
sql " insert into ${tableName} (k, v1, h1) values (4, 4, hll_empty()); " | ||
sql "sync" | ||
qt_insert_into1 """ select HLL_CARDINALITY(h1) from ${tableName} order by k; """ | ||
|
||
// test csv stream load. | ||
streamLoad { | ||
table "${tableName}" | ||
|
||
set 'column_separator', ',' | ||
set 'columns', 'k, v1, h1=hll_hash(k)' | ||
|
||
file 'test_default_hll_streamload.csv' | ||
|
||
time 10000 // limit inflight 10s | ||
} | ||
|
||
sql "sync" | ||
|
||
qt_stream_load_csv1 """ select HLL_CARDINALITY(h1) from ${tableName} order by k; """ | ||
|
||
// test partial update | ||
sql """ DROP TABLE IF EXISTS ${tableName} """ | ||
sql """ | ||
CREATE TABLE IF NOT EXISTS ${tableName} | ||
( | ||
k TINYINT, | ||
v1 DECIMAL(10, 2) DEFAULT "0", | ||
h1 hll NOT NULL COMMENT "hll column" | ||
) | ||
UNIQUE KEY(K) | ||
DISTRIBUTED BY HASH(k) | ||
PROPERTIES("replication_num" = "1"); | ||
""" | ||
|
||
sql "set enable_unique_key_partial_update=true;" | ||
sql "set enable_insert_strict=false;" | ||
|
||
sql " insert into ${tableName} (k, v1) values (1, 1); " | ||
sql " insert into ${tableName} (k, v1) values (2, 2); " | ||
sql " insert into ${tableName} (k, v1) values (3, 3); " | ||
sql " insert into ${tableName} (k, v1) values (4, 4); " | ||
sql "sync" | ||
|
||
qt_select_1 "select HLL_CARDINALITY(h1) from ${tableName} order by k;" | ||
|
||
streamLoad { | ||
table "${tableName}" | ||
|
||
set 'partial_columns', 'true' | ||
set 'column_separator', ',' | ||
set 'columns', 'k, v1' | ||
|
||
file 'test_default_hll_streamload.csv' | ||
|
||
time 10000 // limit inflight 10s | ||
} | ||
|
||
sql "sync" | ||
|
||
qt_stream_load_csv1 """ select HLL_CARDINALITY(h1) from ${tableName} order by k; """ | ||
|
||
} |