yiguolei commented on code in PR #16940: URL: https://github.com/apache/doris/pull/16940#discussion_r1112597312
########## regression-test/suites/load_p0/stream_load_with_sql/test_stream_load_with_sql.groovy: ########## @@ -0,0 +1,490 @@ +// 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. + +import java.util.Random; + +suite("test_stream_load_with_sql", "p0") { + + // csv desc + // | c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8 | + // | int | char | varchar| boolean | tinyint | smallint | bigint | largeint | + // | c9 | c10 | c11 | c12 | c13 | c14 | c15 | c16 | + // | float | double | decimal | decimalv3 | date | datev2 | datetime | datetimev2 | + + // 1. test column with currenttimestamp default value + def tableName1 = "test_stream_load_with_sql_current_timestamp" + def db = "regression_test_load_p0_stream_load_with_sql" + try { + sql """ + CREATE TABLE IF NOT EXISTS ${tableName1} ( + id int, + name CHAR(10), + dt_1 DATETIME DEFAULT CURRENT_TIMESTAMP, + dt_2 DATETIMEV2 DEFAULT CURRENT_TIMESTAMP, + dt_3 DATETIMEV2(3) DEFAULT CURRENT_TIMESTAMP, + dt_4 DATETIMEV2(6) DEFAULT CURRENT_TIMESTAMP + ) + DISTRIBUTED BY HASH(id) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1" + ) + """ + + streamLoad { + set 'version', '1' + set 'sql', """ + insert into ${db}.${tableName1} (id, name) select c1, c2 from stream("format"="csv") + """ + table "${tableName1}" + time 10000 + file 'test_stream_load_with_sql.csv' + check { result, exception, startTime, endTime -> + if (exception != null) { + throw exception + } + log.info("Stream load result: ${result}".toString()) + def json = parseJson(result) + assertEquals("success", json.Status.toLowerCase()) + assertEquals(11, json.NumberTotalRows) + assertEquals(0, json.NumberFilteredRows) + } + } + + qt_sql1 "select id, name from ${tableName1}" + } finally { + try_sql "DROP TABLE IF EXISTS ${tableName1}" + } + + // 2. test change column order + def tableName2 = "test_stream_load_with_sql_change_column_order" + + try { + sql """ + CREATE TABLE IF NOT EXISTS ${tableName2} ( + k1 int, + k2 smallint NOT NULL, + k3 CHAR(10), + k4 bigint NOT NULL, + k5 decimal(6, 3) NOT NULL, + k6 float sum NOT NULL + ) + DISTRIBUTED BY HASH(k1) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1" + ) + """ + + streamLoad { + set 'version', '1' + set 'sql', """ + insert into ${db}.${tableName2} select c1, c6, c2, c7, c11, c9 from stream("format"="csv") + """ + table "${tableName2}" + time 10000 + file 'test_stream_load_with_sql.csv' + check { result, exception, startTime, endTime -> + if (exception != null) { + throw exception + } + log.info("Stream load result: ${result}".toString()) + def json = parseJson(result) + assertEquals("success", json.Status.toLowerCase()) + assertEquals(11, json.NumberTotalRows) + assertEquals(0, json.NumberFilteredRows) + } + } + + qt_sql2 "select * from ${tableName2}" + } finally { + try_sql "DROP TABLE IF EXISTS ${tableName2}" + } + + // 3. test with function + def tableName3 = "test_stream_load_with_sql_function" + + try { + sql """ + CREATE TABLE IF NOT EXISTS ${tableName3} ( + id int, + name CHAR(10), + year int, + month int, + day int + ) + DISTRIBUTED BY HASH(id) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1" + ) + """ + + streamLoad { + set 'version', '1' + set 'sql', """ + insert into ${db}.${tableName3} select c1, c2, year(c14), month(c14), day(c14) from stream("format"="csv") Review Comment: 增加一下 行分隔符、列分隔符的测试case -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org