xiaokang commented on code in PR #16776: URL: https://github.com/apache/doris/pull/16776#discussion_r1108013829
########## be/src/vec/olap/olap_data_convertor.cpp: ########## @@ -786,6 +786,12 @@ Status OlapBlockDataConvertor::OlapColumnDataConvertorArray::convert_to_olap( return Status::OK(); } +void OlapBlockDataConvertor::OlapColumnDataConvertorMap::set_source_column( Review Comment: Is necessary to override set_source_column and just call parent's set_source_column as impl? ########## be/src/vec/exprs/vexpr.cpp: ########## @@ -371,6 +372,15 @@ FunctionContext::TypeDesc VExpr::column_type_to_type_desc(const TypeDescriptor& out.children.push_back(VExpr::column_type_to_type_desc(t)); } break; + case TYPE_MAP: + CHECK(type.children.size() == 2); + // only support map key is scalar + CHECK(!type.children[0].is_complex_type()); + out.type = FunctionContext::TYPE_MAP; + for (const auto& t : type.children) { + out.children.push_back(VExpr::column_type_to_type_desc(t)); + } + break; Review Comment: is TYPE_STRUCT also need to be handled? @xy720 ########## regression-test/suites/map_p0/test_map_load_and_function.groovy: ########## @@ -0,0 +1,90 @@ +// 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 + +suite("test_map_load_and_function", "p0") { + // define a sql table + def testTable = "tbl_test_map" + def dataFile = "test_map.csv" + + sql "DROP TABLE IF EXISTS ${testTable}" + + sql """ + CREATE TABLE IF NOT EXISTS ${testTable} ( + id INT, + m Map<STRING, INT> + ) + DUPLICATE KEY(id) + DISTRIBUTED BY HASH(id) BUCKETS 10 + PROPERTIES("replication_num" = "1"); + """ + + // load the map data from csv file + streamLoad { + table testTable + + file dataFile // import csv file + time 10000 // limit inflight 10s + + // if declared a check callback, the default check condition will ignore. + // So you must check all condition + 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("OK", json.Message) + assertEquals(15, json.NumberTotalRows) + assertTrue(json.LoadBytes > 0) + + } + } + + // check result + qt_select "SELECT * FROM ${testTable} ORDER BY id" + + // insert into valid json rows + sql """INSERT INTO ${testTable} VALUES(12, NULL)""" + sql """INSERT INTO ${testTable} VALUES(13, {"k1":100, "k2": 130})""" + + // map element_at + qt_select "SELECT m['k2'] FROM ${testTable}" + + // map select into outfile + // check outfile + def outFilePath = """${context.file.parent}/tmp""" + logger.warn("test_map_selectOutFile the outFilePath=" + outFilePath) + + File path = new File(outFilePath) + if (path.exists()) { + for (File f: path.listFiles()) { + f.delete(); + } + path.delete(); + } + if (!path.exists()) { + assert path.mkdirs() + } + sql """ + SELECT * FROM ${testTable} INTO OUTFILE "file://${outFilePath}/"; + """ + File[] files = path.listFiles() + assert files.length == 1 Review Comment: should check file content -- 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