amorynan commented on code in PR #28182: URL: https://github.com/apache/doris/pull/28182#discussion_r1423336402
########## regression-test/suites/export_p0/outfile/orc/test_outfile_orc_one_nested_type.groovy: ########## @@ -0,0 +1,447 @@ +// 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 org.codehaus.groovy.runtime.IOGroovyMethods + +import java.nio.charset.StandardCharsets +import java.nio.file.Files +import java.nio.file.Paths + +suite("test_outfile_orc_one_nested_type", "p0") { + // open nereids + sql """ set enable_nereids_planner=true """ + sql """ set enable_fallback_to_original_planner=false """ + + String ak = getS3AK() + String sk = getS3SK() + String s3_endpoint = getS3Endpoint() + String region = getS3Region() + String bucket = context.config.otherConfigs.get("s3BucketName"); + + def export_table_name = "outfile_orc_one_nested_type_export_test" + def outFilePath = "${bucket}/outfile/orc/nested_complex_type/exp_" + def outfile_format = "orc" + + def create_table = {table_name, struct_field -> + sql """ DROP TABLE IF EXISTS ${table_name} """ + sql """ + CREATE TABLE IF NOT EXISTS ${table_name} ( + `user_id` LARGEINT NOT NULL COMMENT "用户id", + `name` STRING COMMENT "用户年龄", + ${struct_field} + ) + DISTRIBUTED BY HASH(user_id) PROPERTIES("replication_num" = "1"); + """ + } + + def outfile_to_S3 = { + // select ... into outfile ... + def res = sql """ + SELECT * FROM ${export_table_name} t ORDER BY user_id + INTO OUTFILE "s3://${outFilePath}" + FORMAT AS ${outfile_format} + PROPERTIES ( + "s3.endpoint" = "${s3_endpoint}", + "s3.region" = "${region}", + "s3.secret_key"="${sk}", + "s3.access_key" = "${ak}" + ); + """ + + return res[0][3] + } + + // 1. test NULL STRUCT_STRUCT + try { + def struct_field_define = "`ss_info` STRUCT<s_info:STRUCT<s_id:int(11), s_name:string, s_address:string>> NULL" + // create table to export data + create_table(export_table_name, struct_field_define) + + // insert data + sql """ insert into ${export_table_name} values (1, 'doris1', {{1, 'sn1', 'sa1'}}); """ + sql """ insert into ${export_table_name} values (2, 'doris2', {{2, 'sn2', 'sa2'}}); """ + sql """ insert into ${export_table_name} values (3, 'doris3', {null}); """ + sql """ insert into ${export_table_name} values (4, 'doris4', null); """ + sql """ insert into ${export_table_name} values (5, 'doris5', {{5, 'sn5', 'sa5'}}); """ + sql """ insert into ${export_table_name} values (6, 'doris6', {{6, 'sn6', 'sa6'}}); """ + sql """ insert into ${export_table_name} values (7, null, {{7, 'sn7', 'sa7'}}); """ + sql """ insert into ${export_table_name} values (8, null, null); """ + + + // test base data + qt_select_base1 """ SELECT * FROM ${export_table_name} t ORDER BY user_id; """ + + def outfile_url = outfile_to_S3() + + qt_select_load1 """ SELECT * FROM S3 ( + "uri" = "http://${s3_endpoint}${outfile_url.substring(4, outfile_url.length() - 1)}0.${outfile_format}", + "ACCESS_KEY"= "${ak}", + "SECRET_KEY" = "${sk}", + "format" = "${outfile_format}", + "region" = "${region}" + ); + """ + } finally { + } + + // 2. test NOT NULL STRUCT_STRUCT + try { + def struct_field_define = "`ss_info` STRUCT<s_info:STRUCT<s_id:int(11), s_name:string, s_address:string>> NOT NULL" + // create table to export data + create_table(export_table_name, struct_field_define) + + // insert data + sql """ insert into ${export_table_name} values (1, 'doris1', {{1, 'sn1', 'sa1'}}); """ Review Comment: we should avoid use struct literal with '{}' which is confused with map literal And struct we only support with function creator, eg. struct(), name_struct() , old struct literal just keep for old client, but we not suggest to use it. -- 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