This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push: new 6b0a642 [feature][vectorized] Support explode json array func #8526 (#8539) 6b0a642 is described below commit 6b0a64239075ac12b825d39ac385d61b11e3be2d Author: Lightman <31928846+lchangli...@users.noreply.github.com> AuthorDate: Sun Apr 3 10:06:47 2022 +0800 [feature][vectorized] Support explode json array func #8526 (#8539) --- be/src/exprs/table_function/explode_json_array.h | 105 +++++++++------- .../table_function/table_function_factory.cpp | 26 +++- be/src/vec/CMakeLists.txt | 1 + .../exprs/table_function/vexplode_json_array.cpp | 85 +++++++++++++ .../table_function/vexplode_json_array.h} | 31 +++-- be/src/vec/functions/function_fake.cpp | 3 + be/src/vec/functions/function_fake.h | 20 +++ .../data/table_function/explose_json_array.out | 136 +++++++++++++++++++++ .../data/table_function/explose_split.out | 33 +++++ .../table_function/explose_json_array.groovy | 64 ++++++++++ .../suites/table_function/explose_split.groovy | 32 +++++ 11 files changed, 479 insertions(+), 57 deletions(-) diff --git a/be/src/exprs/table_function/explode_json_array.h b/be/src/exprs/table_function/explode_json_array.h index 2ebeea4..616535e 100644 --- a/be/src/exprs/table_function/explode_json_array.h +++ b/be/src/exprs/table_function/explode_json_array.h @@ -17,20 +17,16 @@ #pragma once -#include "exprs/table_function/table_function.h" - #include <rapidjson/document.h> #include <rapidjson/stringbuffer.h> + +#include "exprs/table_function/table_function.h" #include "gutil/strings/stringpiece.h" #include "runtime/string_value.h" namespace doris { -enum ExplodeJsonArrayType { - INT = 0, - DOUBLE, - STRING -}; +enum ExplodeJsonArrayType { INT = 0, DOUBLE, STRING }; struct ParsedData { static std::string true_value; @@ -48,53 +44,68 @@ struct ParsedData { void reset(ExplodeJsonArrayType type) { switch (type) { - case ExplodeJsonArrayType::INT: - _data.clear(); - _backup_int.clear(); - break; - case ExplodeJsonArrayType::DOUBLE: - _data.clear(); - _backup_double.clear(); - break; - case ExplodeJsonArrayType::STRING: - _data_string.clear(); - _backup_string.clear(); - _string_nulls.clear(); - break; - default: - CHECK(false) << type; - break; + case ExplodeJsonArrayType::INT: + _data.clear(); + _backup_int.clear(); + break; + case ExplodeJsonArrayType::DOUBLE: + _data.clear(); + _backup_double.clear(); + break; + case ExplodeJsonArrayType::STRING: + _data_string.clear(); + _backup_string.clear(); + _string_nulls.clear(); + break; + default: + CHECK(false) << type; + break; } } void set_null_output(ExplodeJsonArrayType type) { switch (type) { - case ExplodeJsonArrayType::INT: - case ExplodeJsonArrayType::DOUBLE: - _data.resize(1); - _data[0] = nullptr; - break; - case ExplodeJsonArrayType::STRING: - _string_nulls.resize(1); - _string_nulls[0] = true; - break; - default: - CHECK(false) << type; - break; + case ExplodeJsonArrayType::INT: + case ExplodeJsonArrayType::DOUBLE: + _data.resize(1); + _data[0] = nullptr; + break; + case ExplodeJsonArrayType::STRING: + _string_nulls.resize(1); + _string_nulls[0] = true; + break; + default: + CHECK(false) << type; + break; } } - void get_value(ExplodeJsonArrayType type, int64_t offset, void** output) { - switch(type) { - case ExplodeJsonArrayType::INT: - case ExplodeJsonArrayType::DOUBLE: - *output = _data[offset]; - break; - case ExplodeJsonArrayType::STRING: - *output = _string_nulls[offset] ? nullptr : &_data_string[offset]; - break; - default: - CHECK(false) << type; + void get_value(ExplodeJsonArrayType type, int64_t offset, void** output, bool real = false) { + switch (type) { + case ExplodeJsonArrayType::INT: + case ExplodeJsonArrayType::DOUBLE: + *output = _data[offset]; + break; + case ExplodeJsonArrayType::STRING: + *output = _string_nulls[offset] ? nullptr + : real ? reinterpret_cast<void*>(_backup_string[offset].data()) + : &_data_string[offset]; + break; + default: + CHECK(false) << type; + } + } + + void get_value_length(ExplodeJsonArrayType type, int64_t offset, int64_t* length) { + switch (type) { + case ExplodeJsonArrayType::INT: + case ExplodeJsonArrayType::DOUBLE: + break; + case ExplodeJsonArrayType::STRING: + *length = _string_nulls[offset] ? -1 : _backup_string[offset].size(); + break; + default: + CHECK(false) << type; } } @@ -116,7 +127,7 @@ public: private: void _set_null_output(); -private: +protected: ParsedData _parsed_data; ExplodeJsonArrayType _type; diff --git a/be/src/exprs/table_function/table_function_factory.cpp b/be/src/exprs/table_function/table_function_factory.cpp index d0c3954..c347d24 100644 --- a/be/src/exprs/table_function/table_function_factory.cpp +++ b/be/src/exprs/table_function/table_function_factory.cpp @@ -24,6 +24,7 @@ #include "exprs/table_function/table_function.h" #include "vec/exprs/table_function/vexplode_numbers.h" #include "vec/exprs/table_function/vexplode_split.h" +#include "vec/exprs/table_function/vexplode_json_array.h" namespace doris { @@ -38,6 +39,12 @@ struct TableFunctionCreator<ExplodeJsonArrayTableFunction> { TableFunction* operator()() { return new ExplodeJsonArrayTableFunction(type); } }; +template <> +struct TableFunctionCreator<vectorized::VExplodeJsonArrayTableFunction> { + ExplodeJsonArrayType type; + TableFunction* operator()() { return new vectorized::VExplodeJsonArrayTableFunction(type); } +}; + inline auto ExplodeJsonArrayIntCreator = TableFunctionCreator<ExplodeJsonArrayTableFunction> {ExplodeJsonArrayType::INT}; inline auto ExplodeJsonArrayDoubleCreator = @@ -45,18 +52,31 @@ inline auto ExplodeJsonArrayDoubleCreator = inline auto ExplodeJsonArrayStringCreator = TableFunctionCreator<ExplodeJsonArrayTableFunction> {ExplodeJsonArrayType::STRING}; +inline auto VExplodeJsonArrayIntCreator = + TableFunctionCreator<vectorized::VExplodeJsonArrayTableFunction> { + ExplodeJsonArrayType::INT}; +inline auto VExplodeJsonArrayDoubleCreator = + TableFunctionCreator<vectorized::VExplodeJsonArrayTableFunction> { + ExplodeJsonArrayType::DOUBLE}; +inline auto VExplodeJsonArrayStringCreator = + TableFunctionCreator<vectorized::VExplodeJsonArrayTableFunction> { + ExplodeJsonArrayType::STRING}; + //{fn_name,is_vectorized}->table_function_creator const std::unordered_map<std::pair<std::string, bool>, std::function<TableFunction*()>> TableFunctionFactory::_function_map { - {{"explode_split", false}, TableFunctionCreator<ExplodeSplitTableFunction>()}, - {{"explode_bitmap", false}, TableFunctionCreator<ExplodeBitmapTableFunction>()}, + {{"explode_split", false}, TableFunctionCreator<ExplodeSplitTableFunction> {}}, + {{"explode_bitmap", false}, TableFunctionCreator<ExplodeBitmapTableFunction> {}}, {{"explode_json_array_int", false}, ExplodeJsonArrayIntCreator}, {{"explode_json_array_double", false}, ExplodeJsonArrayDoubleCreator}, {{"explode_json_array_string", false}, ExplodeJsonArrayStringCreator}, {{"explode_split", true}, TableFunctionCreator<vectorized::VExplodeSplitTableFunction>()}, {{"explode_numbers", true}, - TableFunctionCreator<vectorized::VExplodeNumbersTableFunction>()}}; + TableFunctionCreator<vectorized::VExplodeNumbersTableFunction>()}, + {{"explode_json_array_int", true}, VExplodeJsonArrayIntCreator}, + {{"explode_json_array_double", true}, VExplodeJsonArrayDoubleCreator}, + {{"explode_json_array_string", true}, VExplodeJsonArrayStringCreator}}; Status TableFunctionFactory::get_fn(const std::string& fn_name, bool is_vectorized, ObjectPool* pool, TableFunction** fn) { diff --git a/be/src/vec/CMakeLists.txt b/be/src/vec/CMakeLists.txt index 9dc5089..f8ffea4 100644 --- a/be/src/vec/CMakeLists.txt +++ b/be/src/vec/CMakeLists.txt @@ -115,6 +115,7 @@ set(VEC_FILES functions/array/function_array_index.cpp functions/array/function_array_element.cpp functions/array/function_array_register.cpp + exprs/table_function/vexplode_json_array.cpp functions/math.cpp functions/function_bitmap.cpp functions/function_bitmap_variadic.cpp diff --git a/be/src/vec/exprs/table_function/vexplode_json_array.cpp b/be/src/vec/exprs/table_function/vexplode_json_array.cpp new file mode 100644 index 0000000..aedcc53 --- /dev/null +++ b/be/src/vec/exprs/table_function/vexplode_json_array.cpp @@ -0,0 +1,85 @@ +// 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. + +#include "vec/exprs/table_function/vexplode_json_array.h" + +#include "common/status.h" +#include "vec/exprs/vexpr.h" + +namespace doris::vectorized { + +VExplodeJsonArrayTableFunction::VExplodeJsonArrayTableFunction(ExplodeJsonArrayType type) + : ExplodeJsonArrayTableFunction(type) { + _fn_name = "vexplode_json_array"; +} + +Status VExplodeJsonArrayTableFunction::process_init(vectorized::Block* block) { + CHECK(_vexpr_context->root()->children().size() == 1) + << _vexpr_context->root()->children().size(); + + int text_column_idx = -1; + _vexpr_context->root()->children()[0]->execute(_vexpr_context, block, &text_column_idx); + _text_column = block->get_by_position(text_column_idx).column; + + return Status::OK(); +} + +Status VExplodeJsonArrayTableFunction::process_row(size_t row_idx) { + _is_current_empty = false; + _eos = false; + + StringRef text = _text_column->get_data_at(row_idx); + if (text.data == nullptr) { + _is_current_empty = true; + } else { + rapidjson::Document document; + document.Parse(text.data, text.size); + if (UNLIKELY(document.HasParseError()) || !document.IsArray() || + document.GetArray().Size() == 0) { + _is_current_empty = true; + } else { + _cur_size = _parsed_data.set_output(_type, document); + _cur_offset = 0; + } + } + return Status::OK(); +} + +Status VExplodeJsonArrayTableFunction::process_close() { + _text_column = nullptr; + return Status::OK(); +} + +Status VExplodeJsonArrayTableFunction::get_value_length(int64_t* length) { + if (_is_current_empty) { + *length = -1; + } else { + _parsed_data.get_value_length(_type, _cur_offset, length); + } + return Status::OK(); +} + +Status VExplodeJsonArrayTableFunction::get_value(void** output) { + if (_is_current_empty) { + *output = nullptr; + } else { + _parsed_data.get_value(_type, _cur_offset, output, true); + } + return Status::OK(); +} + +} // namespace doris::vectorized \ No newline at end of file diff --git a/be/src/vec/functions/function_fake.cpp b/be/src/vec/exprs/table_function/vexplode_json_array.h similarity index 50% copy from be/src/vec/functions/function_fake.cpp copy to be/src/vec/exprs/table_function/vexplode_json_array.h index 4eab7ab..8c496c3 100644 --- a/be/src/vec/functions/function_fake.cpp +++ b/be/src/vec/exprs/table_function/vexplode_json_array.h @@ -15,14 +15,31 @@ // specific language governing permissions and limitations // under the License. -#include "vec/functions/function_fake.h" +#pragma once + +#include <rapidjson/document.h> +#include <rapidjson/stringbuffer.h> + +#include "exprs/table_function/explode_json_array.h" +#include "gutil/strings/stringpiece.h" +#include "runtime/string_value.h" +#include "vec/columns/column.h" namespace doris::vectorized { -void register_function_fake(SimpleFunctionFactory& factory) { - factory.register_function<FunctionFake<FunctionEsqueryImpl>>(); - factory.register_function<FunctionFake<FunctionExplodeSplitImpl>>(); - factory.register_function<FunctionFake<FunctionExplodeNumbersImpl>>(); -} +class VExplodeJsonArrayTableFunction : public ExplodeJsonArrayTableFunction { +public: + VExplodeJsonArrayTableFunction(ExplodeJsonArrayType type); + virtual ~VExplodeJsonArrayTableFunction() = default; + + virtual Status process_init(vectorized::Block* block) override; + virtual Status process_row(size_t row_idx) override; + virtual Status process_close() override; + virtual Status get_value(void** output) override; + virtual Status get_value_length(int64_t* length) override; + +private: + ColumnPtr _text_column; +}; -} // namespace doris::vectorized +} // namespace doris::vectorized \ No newline at end of file diff --git a/be/src/vec/functions/function_fake.cpp b/be/src/vec/functions/function_fake.cpp index 4eab7ab..eb6e875 100644 --- a/be/src/vec/functions/function_fake.cpp +++ b/be/src/vec/functions/function_fake.cpp @@ -23,6 +23,9 @@ void register_function_fake(SimpleFunctionFactory& factory) { factory.register_function<FunctionFake<FunctionEsqueryImpl>>(); factory.register_function<FunctionFake<FunctionExplodeSplitImpl>>(); factory.register_function<FunctionFake<FunctionExplodeNumbersImpl>>(); + factory.register_function<FunctionFake<FunctionExplodeJsonArrayDoubleImpl>>(); + factory.register_function<FunctionFake<FunctionExplodeJsonArrayIntImpl>>(); + factory.register_function<FunctionFake<FunctionExplodeJsonArrayStringImpl>>(); } } // namespace doris::vectorized diff --git a/be/src/vec/functions/function_fake.h b/be/src/vec/functions/function_fake.h index 22cd3c7..6e70eb8 100644 --- a/be/src/vec/functions/function_fake.h +++ b/be/src/vec/functions/function_fake.h @@ -47,6 +47,26 @@ struct FunctionExplodeNumbersImpl { } }; +struct FunctionExplodeJsonArrayIntImpl { + static constexpr auto name = "explode_json_array_int"; + static DataTypePtr get_return_type_impl(const DataTypes& arguments) { + return std::make_shared<DataTypeInt64>(); + } +}; + +struct FunctionExplodeJsonArrayStringImpl { + static constexpr auto name = "explode_json_array_string"; + static DataTypePtr get_return_type_impl(const DataTypes& arguments) { + return std::make_shared<DataTypeString>(); + } +}; + +struct FunctionExplodeJsonArrayDoubleImpl { + static constexpr auto name = "explode_json_array_double"; + static DataTypePtr get_return_type_impl(const DataTypes& arguments) { + return std::make_shared<DataTypeFloat64>(); + } +}; //FunctionFake is use for some function call expr only work at prepare/open phase, do not support execute(). template <typename Impl> class FunctionFake : public IFunction { diff --git a/regression-test/data/table_function/explose_json_array.out b/regression-test/data/table_function/explose_json_array.out new file mode 100644 index 0000000..4352156 --- /dev/null +++ b/regression-test/data/table_function/explose_json_array.out @@ -0,0 +1,136 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !explose_json_array -- +100 John 30 1 Street 1 40 30 +100 John 30 1 Street 1 80 30 +100 John 30 1 Street 1 40 60 +100 John 30 1 Street 1 80 60 +200 Mary \N 1 Street 2 40 30 +200 Mary \N 1 Street 2 80 30 +200 Mary \N 1 Street 2 40 60 +200 Mary \N 1 Street 2 80 60 +300 Mike 80 3 Street 3 40 30 +300 Mike 80 3 Street 3 80 30 +300 Mike 80 3 Street 3 40 60 +300 Mike 80 3 Street 3 80 60 +400 Dan 50 4 Street 4 40 30 +400 Dan 50 4 Street 4 80 30 +400 Dan 50 4 Street 4 40 60 +400 Dan 50 4 Street 4 80 60 + +-- !explose_json_array -- +30 8 +60 8 + +-- !explose_json_array -- +100 John 30 1 Street 1 \N +200 Mary \N 1 Street 2 \N +300 Mike 80 3 Street 3 \N +400 Dan 50 4 Street 4 \N + +-- !explose_json_array -- +100 John 30 1 Street 1 1.23 1 +100 John 30 1 Street 1 22.214 1 +100 John 30 1 Street 1 214.1 1 +100 John 30 1 Street 1 1.23 3 +100 John 30 1 Street 1 22.214 3 +100 John 30 1 Street 1 214.1 3 +100 John 30 1 Street 1 1.23 b +100 John 30 1 Street 1 22.214 b +100 John 30 1 Street 1 214.1 b +200 Mary \N 1 Street 2 1.23 1 +200 Mary \N 1 Street 2 22.214 1 +200 Mary \N 1 Street 2 214.1 1 +200 Mary \N 1 Street 2 1.23 3 +200 Mary \N 1 Street 2 22.214 3 +200 Mary \N 1 Street 2 214.1 3 +200 Mary \N 1 Street 2 1.23 b +200 Mary \N 1 Street 2 22.214 b +200 Mary \N 1 Street 2 214.1 b +300 Mike 80 3 Street 3 1.23 1 +300 Mike 80 3 Street 3 22.214 1 +300 Mike 80 3 Street 3 214.1 1 +300 Mike 80 3 Street 3 1.23 3 +300 Mike 80 3 Street 3 22.214 3 +300 Mike 80 3 Street 3 214.1 3 +300 Mike 80 3 Street 3 1.23 b +300 Mike 80 3 Street 3 22.214 b +300 Mike 80 3 Street 3 214.1 b +400 Dan 50 4 Street 4 1.23 1 +400 Dan 50 4 Street 4 22.214 1 +400 Dan 50 4 Street 4 214.1 1 +400 Dan 50 4 Street 4 1.23 3 +400 Dan 50 4 Street 4 22.214 3 +400 Dan 50 4 Street 4 214.1 3 +400 Dan 50 4 Street 4 1.23 b +400 Dan 50 4 Street 4 22.214 b +400 Dan 50 4 Street 4 214.1 b + +-- !explose_json_array -- +true + +-- !explose_json_array -- +100 John 30 1 Street 1 40 30 +100 John 30 1 Street 1 80 30 +100 John 30 1 Street 1 40 60 +100 John 30 1 Street 1 80 60 +200 Mary \N 1 Street 2 40 30 +200 Mary \N 1 Street 2 80 30 +200 Mary \N 1 Street 2 40 60 +200 Mary \N 1 Street 2 80 60 +300 Mike 80 3 Street 3 40 30 +300 Mike 80 3 Street 3 80 30 +300 Mike 80 3 Street 3 40 60 +300 Mike 80 3 Street 3 80 60 +400 Dan 50 4 Street 4 40 30 +400 Dan 50 4 Street 4 80 30 +400 Dan 50 4 Street 4 40 60 +400 Dan 50 4 Street 4 80 60 + +-- !explose_json_array -- +30 8 +60 8 + +-- !explose_json_array -- +100 John 30 1 Street 1 \N +200 Mary \N 1 Street 2 \N +300 Mike 80 3 Street 3 \N +400 Dan 50 4 Street 4 \N + +-- !explose_json_array -- +100 John 30 1 Street 1 1.23 1 +100 John 30 1 Street 1 22.214 1 +100 John 30 1 Street 1 214.1 1 +100 John 30 1 Street 1 1.23 3 +100 John 30 1 Street 1 22.214 3 +100 John 30 1 Street 1 214.1 3 +100 John 30 1 Street 1 1.23 b +100 John 30 1 Street 1 22.214 b +100 John 30 1 Street 1 214.1 b +200 Mary \N 1 Street 2 1.23 1 +200 Mary \N 1 Street 2 22.214 1 +200 Mary \N 1 Street 2 214.1 1 +200 Mary \N 1 Street 2 1.23 3 +200 Mary \N 1 Street 2 22.214 3 +200 Mary \N 1 Street 2 214.1 3 +200 Mary \N 1 Street 2 1.23 b +200 Mary \N 1 Street 2 22.214 b +200 Mary \N 1 Street 2 214.1 b +300 Mike 80 3 Street 3 1.23 1 +300 Mike 80 3 Street 3 22.214 1 +300 Mike 80 3 Street 3 214.1 1 +300 Mike 80 3 Street 3 1.23 3 +300 Mike 80 3 Street 3 22.214 3 +300 Mike 80 3 Street 3 214.1 3 +300 Mike 80 3 Street 3 1.23 b +300 Mike 80 3 Street 3 22.214 b +300 Mike 80 3 Street 3 214.1 b +400 Dan 50 4 Street 4 1.23 1 +400 Dan 50 4 Street 4 22.214 1 +400 Dan 50 4 Street 4 214.1 1 +400 Dan 50 4 Street 4 1.23 3 +400 Dan 50 4 Street 4 22.214 3 +400 Dan 50 4 Street 4 214.1 3 +400 Dan 50 4 Street 4 1.23 b +400 Dan 50 4 Street 4 22.214 b +400 Dan 50 4 Street 4 214.1 b + diff --git a/regression-test/data/table_function/explose_split.out b/regression-test/data/table_function/explose_split.out new file mode 100644 index 0000000..6e85625 --- /dev/null +++ b/regression-test/data/table_function/explose_split.out @@ -0,0 +1,33 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !explose_split -- +1 a,b,c a +1 a,b,c b +1 a,b,c c + +-- !explose_split -- +1 a,b,c a a +1 a,b,c a b +1 a,b,c a c +1 a,b,c b a +1 a,b,c b b +1 a,b,c b c +1 a,b,c c a +1 a,b,c c b +1 a,b,c c c + +-- !explose_split -- +1 a,b,c a +1 a,b,c b +1 a,b,c c + +-- !explose_split -- +1 a,b,c a a +1 a,b,c a b +1 a,b,c a c +1 a,b,c b a +1 a,b,c b b +1 a,b,c b c +1 a,b,c c a +1 a,b,c c b +1 a,b,c c c + diff --git a/regression-test/suites/table_function/explose_json_array.groovy b/regression-test/suites/table_function/explose_json_array.groovy new file mode 100644 index 0000000..ed75450 --- /dev/null +++ b/regression-test/suites/table_function/explose_json_array.groovy @@ -0,0 +1,64 @@ +// The cases is copied from +// https://spark.apache.org/docs/latest/sql-ref-syntax-qry-select-lateral-view.html +// and modified by Doris. + +def tableName = "person" + +sql """ DROP TABLE IF EXISTS ${tableName} """ +sql """ + CREATE TABLE ${tableName} + (id INT, name STRING, age INT, class INT, address STRING) + UNIQUE KEY(id) DISTRIBUTED BY HASH(id) BUCKETS 8 + PROPERTIES("replication_num" = "1") +""" + +sql """ INSERT INTO ${tableName} VALUES + (100, 'John', 30, 1, 'Street 1'), + (200, 'Mary', NULL, 1, 'Street 2'), + (300, 'Mike', 80, 3, 'Street 3'), + (400, 'Dan', 50, 4, 'Street 4') """ + +sql """ set enable_lateral_view = true """ + +// not vectorized +qt_explose_json_array """ SELECT * FROM ${tableName} + LATERAL VIEW EXPLODE_JSON_ARRAY_INT('[30, 60]') t1 as c_age + LATERAL VIEW EXPLODE_JSON_ARRAY_INT('[40, 80]') t2 as d_age + ORDER BY id, c_age, d_age """ + +qt_explose_json_array """ SELECT c_age, COUNT(1) FROM ${tableName} + LATERAL VIEW EXPLODE_JSON_ARRAY_INT('[30, 60]') t1 as c_age + LATERAL VIEW EXPLODE_JSON_ARRAY_INT('[40, 80]') t2 as d_age + GROUP BY c_age ORDER BY c_age """ + +qt_explose_json_array """ SELECT * FROM ${tableName} + LATERAL VIEW EXPLODE_JSON_ARRAY_INT('[]') t1 AS c_age + ORDER BY id, c_age """ + +qt_explose_json_array """ SELECT * FROM ${tableName} + LATERAL VIEW EXPLODE_JSON_ARRAY_STRING('[1, "b", 3]') t1 as c + LATERAL VIEW EXPLODE_JSON_ARRAY_DOUBLE('[1.23, 22.214, 214.1]') t2 as d + ORDER BY id, c, d """ + +// vectorized +sql """ set enable_vectorized_engine = true """ + +qt_explose_json_array """ select @@enable_vectorized_engine """ +qt_explose_json_array """ SELECT * FROM ${tableName} + LATERAL VIEW EXPLODE_JSON_ARRAY_INT('[30, 60]') t1 as c_age + LATERAL VIEW EXPLODE_JSON_ARRAY_INT('[40, 80]') t2 as d_age + ORDER BY id, c_age, d_age """ + +qt_explose_json_array """ SELECT c_age, COUNT(1) FROM ${tableName} + LATERAL VIEW EXPLODE_JSON_ARRAY_INT('[30, 60]') t1 as c_age + LATERAL VIEW EXPLODE_JSON_ARRAY_INT('[40, 80]') t2 as d_age + GROUP BY c_age ORDER BY c_age """ + +qt_explose_json_array """ SELECT * FROM ${tableName} + LATERAL VIEW EXPLODE_JSON_ARRAY_INT('[]') t1 AS c_age + ORDER BY id, c_age """ + +qt_explose_json_array """ SELECT * FROM ${tableName} + LATERAL VIEW EXPLODE_JSON_ARRAY_STRING('[1, "b", 3]') t1 as c + LATERAL VIEW EXPLODE_JSON_ARRAY_DOUBLE('[1.23, 22.214, 214.1]') t2 as d + ORDER BY id, c, d """ \ No newline at end of file diff --git a/regression-test/suites/table_function/explose_split.groovy b/regression-test/suites/table_function/explose_split.groovy new file mode 100644 index 0000000..429c5a3 --- /dev/null +++ b/regression-test/suites/table_function/explose_split.groovy @@ -0,0 +1,32 @@ +def tableName = "test_lv_str" + +sql """ DROP TABLE IF EXISTS ${tableName} """ +sql """ + CREATE TABLE ${tableName} + (k1 INT, k2 STRING) + UNIQUE KEY(k1) DISTRIBUTED BY HASH(k1) BUCKETS 8 + PROPERTIES("replication_num" = "1") +""" + +sql """ INSERT INTO ${tableName} VALUES (1, 'a,b,c') """ + +sql """ set enable_lateral_view = true """ + +// not_vectorized +qt_explose_split """ select * from ${tableName} + lateral view explode_split(k2, ',') tmp1 as e1 """ + +qt_explose_split """ select * from ${tableName} + lateral view explode_split(k2, ',') tmp1 as e1 + lateral view explode_split(k2, ',') tmp2 as e2 """ + +// vectorized +sql """ set enable_vectorized_engine = true """ + +qt_explose_split """ select * from ${tableName} + lateral view explode_split(k2, ',') tmp1 as e1 """ + +qt_explose_split """ select * from ${tableName} + lateral view explode_split(k2, ',') tmp1 as e1 + lateral view explode_split(k2, ',') tmp2 as e2 """ + --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org