branch-2.1: [Bug](function) fix Could not find function explode_json_array_json_outer #50164 (#50227)
Cherry-picked from #50164 Co-authored-by: zhangstar333 <zhangsida@selectdb.com>
This commit is contained in:
committed by
GitHub
parent
b866068217
commit
b0c8cb0818
@ -49,9 +49,6 @@ struct FunctionFakeBaseImpl {
|
||||
}
|
||||
static DataTypes get_variadic_argument_types() {
|
||||
if constexpr (VARIADIC) {
|
||||
if constexpr (AlwaysNullable) {
|
||||
return {make_nullable(std::make_shared<ReturnType>())};
|
||||
}
|
||||
return {std::make_shared<ReturnType>()};
|
||||
} else {
|
||||
return {};
|
||||
|
||||
@ -19,7 +19,7 @@ package org.apache.doris.nereids.trees.expressions.functions.generator;
|
||||
|
||||
import org.apache.doris.catalog.FunctionSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.Expression;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
|
||||
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.JsonType;
|
||||
@ -34,7 +34,7 @@ import java.util.List;
|
||||
* explode_json_array_json_outer("[{"id":1,"name":"John"},{"id":2,"name":"Mary"},{"id":3,"name":"Bob"}]"),
|
||||
* generate 3 lines include '{"id":1,"name":"John"}', '{"id":2,"name":"Mary"}' and '{"id":3,"name":"Bob"}'.
|
||||
*/
|
||||
public class ExplodeJsonArrayJsonOuter extends TableGeneratingFunction implements UnaryExpression, PropagateNullable {
|
||||
public class ExplodeJsonArrayJsonOuter extends TableGeneratingFunction implements UnaryExpression, AlwaysNullable {
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(JsonType.INSTANCE).args(JsonType.INSTANCE),
|
||||
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT)
|
||||
|
||||
@ -227,3 +227,8 @@
|
||||
400 Dan 50 4 Street 4 22.214 b
|
||||
400 Dan 50 4 Street 4 214.1 b
|
||||
|
||||
-- !explode_json_array17 --
|
||||
4 {"a":1}
|
||||
4 {"b":2}
|
||||
4 {"c":3}
|
||||
|
||||
|
||||
@ -89,5 +89,32 @@ suite("explode_json_array") {
|
||||
qt_explode_json_array16 """ SELECT id, name, age, class, address, d, c FROM person
|
||||
LATERAL VIEW EXPLODE_JSON_ARRAY_STRING('[null, "b", null]') t1 as c
|
||||
LATERAL VIEW EXPLODE_JSON_ARRAY_DOUBLE('[1.23, 22.214, 214.1]') t2 as d
|
||||
ORDER BY id, c, d """
|
||||
ORDER BY id, c, d """
|
||||
sql """ DROP TABLE IF EXISTS json_array_example """
|
||||
sql """
|
||||
CREATE TABLE json_array_example (
|
||||
id INT,
|
||||
json_array STRING
|
||||
)DUPLICATE KEY(id)
|
||||
DISTRIBUTED BY HASH(id) BUCKETS AUTO
|
||||
PROPERTIES (
|
||||
"replication_allocation" = "tag.location.default: 1");
|
||||
"""
|
||||
sql """
|
||||
INSERT INTO json_array_example (id, json_array) VALUES
|
||||
(1, '[1, 2, 3, 4, 5]'),
|
||||
(2, '[1.1, 2.2, 3.3, 4.4]'),
|
||||
(3, '["apple", "banana", "cherry"]'),
|
||||
(4, '[{"a": 1}, {"b": 2}, {"c": 3}]'),
|
||||
(5, '[]'),
|
||||
(6, 'NULL');
|
||||
"""
|
||||
|
||||
qt_explode_json_array17 """
|
||||
SELECT id, e1
|
||||
FROM json_array_example
|
||||
LATERAL VIEW EXPLODE_JSON_ARRAY_JSON_OUTER(json_array) tmp1 AS e1
|
||||
WHERE id = 4 order by id, e1;
|
||||
"""
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user