From 60db4e23335798d6a96126e08dbe39681eb78a1f Mon Sep 17 00:00:00 2001 From: tsy Date: Thu, 24 Aug 2023 17:54:03 +0800 Subject: [PATCH 1/2] fix --- .../src/main/java/org/apache/doris/planner/FileLoadScanNode.java | 1 + 1 file changed, 1 insertion(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/FileLoadScanNode.java b/fe/fe-core/src/main/java/org/apache/doris/planner/FileLoadScanNode.java index b672b309306122..17398a5491ccb6 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/FileLoadScanNode.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/FileLoadScanNode.java @@ -255,6 +255,7 @@ protected void finalizeParamsForLoad(ParamCreateContext context, if (column.getDefaultValue() != null) { if (column.getDefaultValueExprDef() != null) { expr = column.getDefaultValueExpr(); + expr.analyze(analyzer); } else { expr = new StringLiteral(destSlotDesc.getColumn().getDefaultValue()); } From ef138947a2afbbdb5f7b566136c7c776d248b6fa Mon Sep 17 00:00:00 2001 From: tsy Date: Thu, 24 Aug 2023 19:04:17 +0800 Subject: [PATCH 2/2] add user case --- .../correctness_p0/test_current_timestamp.out | 6 ++ .../test_current_timestamp_dft.csv | 2 + .../test_current_timestamp_dft.json | 2 + .../test_current_timestamp.groovy | 67 ++++++++++++++++++- 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 regression-test/data/correctness_p0/test_current_timestamp_dft.csv create mode 100644 regression-test/data/correctness_p0/test_current_timestamp_dft.json diff --git a/regression-test/data/correctness_p0/test_current_timestamp.out b/regression-test/data/correctness_p0/test_current_timestamp.out index 30601403742f1a..cdf3ca219e3e44 100644 --- a/regression-test/data/correctness_p0/test_current_timestamp.out +++ b/regression-test/data/correctness_p0/test_current_timestamp.out @@ -51,3 +51,9 @@ -- !select_sql -- 2 +-- !select -- +2 + +-- !select -- +2 + diff --git a/regression-test/data/correctness_p0/test_current_timestamp_dft.csv b/regression-test/data/correctness_p0/test_current_timestamp_dft.csv new file mode 100644 index 00000000000000..b93fa0f52b6f69 --- /dev/null +++ b/regression-test/data/correctness_p0/test_current_timestamp_dft.csv @@ -0,0 +1,2 @@ +1,2010-11-30 23:59:59.281000 +2,2011-11-30 23:59:59.281000 \ No newline at end of file diff --git a/regression-test/data/correctness_p0/test_current_timestamp_dft.json b/regression-test/data/correctness_p0/test_current_timestamp_dft.json new file mode 100644 index 00000000000000..b7a11cb1c7776d --- /dev/null +++ b/regression-test/data/correctness_p0/test_current_timestamp_dft.json @@ -0,0 +1,2 @@ +{"id":1,"name":"aa"} +{"id":2,"name":"bb"} \ No newline at end of file diff --git a/regression-test/suites/correctness_p0/test_current_timestamp.groovy b/regression-test/suites/correctness_p0/test_current_timestamp.groovy index e4673259e6e3e0..6471f866169f9c 100644 --- a/regression-test/suites/correctness_p0/test_current_timestamp.groovy +++ b/regression-test/suites/correctness_p0/test_current_timestamp.groovy @@ -215,4 +215,69 @@ suite("test_current_timestamp") { """ exception "errCode = 2, detailMessage = Internal Error, maybe syntax error or this is a bug: column's default value current_timestamp precision must be between 0 and 6" } - } + + // user case + def tableName6 = "test_current_timestamp_4" + sql """ DROP TABLE IF EXISTS ${tableName6} """ + sql """ + CREATE TABLE IF NOT EXISTS ${tableName6} + ( + `id` int, + `date_time` datetime(3), + `data_entry_time` datetime(3) NULL DEFAULT CURRENT_TIMESTAMP(3) + ) DUPLICATE KEY(`id`) + DISTRIBUTED BY HASH(id) + PROPERTIES + ( + "replication_num" = "1" + ); + """ + + streamLoad { + table "${tableName6}" + set 'columns', 'id,date_time' + set 'format', 'csv' + set 'column_separator', ',' + + file "test_current_timestamp_dft.csv" + + time 10000 + } + + sql "sync" + qt_select """ select count(*) from ${tableName6} """ + + def tableName7 = "test_current_timestamp_5" + sql """ DROP TABLE IF EXISTS ${tableName7} """ + sql """ + CREATE TABLE ${tableName7} ( + id int, + `name` varchar(50) NULL, + input_time datetime default current_timestamp + ) ENGINE=OLAP + DUPLICATE KEY(`id`) + COMMENT 'OLAP' + DISTRIBUTED BY HASH(`id`) BUCKETS 10 + PROPERTIES ( + "in_memory" = "false", + "storage_format" = "V2", + "replication_num" = "1" + ); + """ + + streamLoad { + table "${tableName7}" + set 'columns', 'id,name' + set 'format', 'json' + set 'read_json_by_line', 'true' + set 'strip_outer_array', 'false' + + file "test_current_timestamp_dft.json" + + time 10000 + } + + sql "sync" + qt_select """ select count(*) from ${tableName7} """ + +}