From ee089585269fe006319a6a3f6806b69b7fab49bd Mon Sep 17 00:00:00 2001 From: Guangdong Liu <804167098@qq.com> Date: Fri, 17 Nov 2023 13:36:41 +0800 Subject: [PATCH] [regression test](http_stream) case for timezone (#27149) It does not work now, anyway we need a case. --- .../load_p0/http_stream/test_http_stream.out | 15 ++++ .../http_stream/test_http_stream.groovy | 77 ++++++++++++++++++- 2 files changed, 90 insertions(+), 2 deletions(-) diff --git a/regression-test/data/load_p0/http_stream/test_http_stream.out b/regression-test/data/load_p0/http_stream/test_http_stream.out index 5b6d8411bf..6c2865881a 100644 --- a/regression-test/data/load_p0/http_stream/test_http_stream.out +++ b/regression-test/data/load_p0/http_stream/test_http_stream.out @@ -582,3 +582,18 @@ 10009 jj 10010 kk +-- !sql15 -- +10000 aa 0 +10001 bb 0 +10002 cc 0 +10003 dd 0 +10004 ee 0 +10005 ff 0 +10006 gg 0 +10007 hh 0 +10008 ii 0 +10009 jj 0 +10010 kk 0 + +-- !sql15_1 -- + diff --git a/regression-test/suites/load_p0/http_stream/test_http_stream.groovy b/regression-test/suites/load_p0/http_stream/test_http_stream.groovy index d504078635..ad795e947a 100644 --- a/regression-test/suites/load_p0/http_stream/test_http_stream.groovy +++ b/regression-test/suites/load_p0/http_stream/test_http_stream.groovy @@ -15,8 +15,6 @@ // specific language governing permissions and limitations // under the License. -import java.util.Random; - suite("test_http_stream", "p0") { // csv desc @@ -640,5 +638,80 @@ suite("test_http_stream", "p0") { } finally { try_sql "DROP TABLE IF EXISTS ${tableName14}" } + + // 15. test timezone + def tableName15 = "test_http_stream_timezone" + + try { + sql """ + CREATE TABLE IF NOT EXISTS ${tableName15} ( + id int, + name CHAR(10), + cc int + ) + DISTRIBUTED BY HASH(id) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1" + ) + """ + + streamLoad { + set 'version', '1' + set 'timezone', 'America/Los_Angeles' + set 'sql', """ + insert into ${db}.${tableName15} select c1, c2 , UNIX_TIMESTAMP('1970-01-01 08:00:00') from http_stream("format"="csv", "column_separator"="--") + """ + time 10000 + file 'test_http_stream_column_separator.csv' + check { result, exception, startTime, endTime -> + if (exception != null) { + throw exception + } + log.info("http_stream result: ${result}".toString()) + def json = parseJson(result) + assertEquals("success", json.Status.toLowerCase()) + } + } + + qt_sql15 "select id, name, cc from ${tableName15} order by id" + } finally { + try_sql "DROP TABLE IF EXISTS ${tableName15}" + } + + try { + sql """ + CREATE TABLE IF NOT EXISTS ${tableName15} ( + id int, + name CHAR(10), + cc int + ) + DISTRIBUTED BY HASH(id) BUCKETS 1 + PROPERTIES ( + "replication_num" = "1" + ) + """ + + // TODO Wait until http_stream function is perfected. + streamLoad { + set 'version', '1' + set 'timezone', 'Test' + set 'sql', """ + insert into ${db}.${tableName15} select c1, c2 , UNIX_TIMESTAMP('1970-01-01 08:00:00') from http_stream("format"="csv", "column_separator"="--") + """ + time 10000 + file 'test_http_stream_column_separator.csv' + check { result, exception, startTime, endTime -> + if (exception != null) { + throw exception + } + log.info("http_stream result: ${result}".toString()) + def json = parseJson(result) + assertEquals("success", json.Status.toLowerCase()) + } + qt_sql15_1 "select id, name, cc from ${tableName15} order by id" + } + } finally { + try_sql "DROP TABLE IF EXISTS ${tableName15}" + } }