diff --git a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/SeaTunnelDataTypeConvertorUtil.java b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/SeaTunnelDataTypeConvertorUtil.java index c5109f2e14e..5721185ac59 100644 --- a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/SeaTunnelDataTypeConvertorUtil.java +++ b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/SeaTunnelDataTypeConvertorUtil.java @@ -230,6 +230,9 @@ private static SeaTunnelDataType parseArrayType(String field, String columnSt return ArrayType.FLOAT_ARRAY_TYPE; case DOUBLE: return ArrayType.DOUBLE_ARRAY_TYPE; + case MAP: + return new ArrayType<>( + MapType.class, new MapType<>(BasicType.STRING_TYPE, BasicType.STRING_TYPE)); default: throw CommonError.unsupportedDataType("SeaTunnel", genericType, field); } diff --git a/seatunnel-e2e/seatunnel-transforms-v2-e2e/seatunnel-transforms-v2-e2e-part-2/src/test/java/org/apache/seatunnel/e2e/transform/TestJsonPathTransformIT.java b/seatunnel-e2e/seatunnel-transforms-v2-e2e/seatunnel-transforms-v2-e2e-part-2/src/test/java/org/apache/seatunnel/e2e/transform/TestJsonPathTransformIT.java index 3bc4b0cc70a..7e2dd35bd64 100644 --- a/seatunnel-e2e/seatunnel-transforms-v2-e2e/seatunnel-transforms-v2-e2e-part-2/src/test/java/org/apache/seatunnel/e2e/transform/TestJsonPathTransformIT.java +++ b/seatunnel-e2e/seatunnel-transforms-v2-e2e/seatunnel-transforms-v2-e2e-part-2/src/test/java/org/apache/seatunnel/e2e/transform/TestJsonPathTransformIT.java @@ -59,4 +59,11 @@ public void testErrorHandleWay(TestContainer container) throws Exception { container.executeJob("/json_path_transform/json_path_with_error_handle_way.conf"); Assertions.assertEquals(0, execResult.getExitCode()); } + + @TestTemplate + public void testArrayType(TestContainer container) throws Exception { + Container.ExecResult execResult = + container.executeJob("/json_path_transform/json_path_array_map.conf"); + Assertions.assertEquals(0, execResult.getExitCode()); + } } diff --git a/seatunnel-e2e/seatunnel-transforms-v2-e2e/seatunnel-transforms-v2-e2e-part-2/src/test/resources/json_path_transform/json_path_array_map.conf b/seatunnel-e2e/seatunnel-transforms-v2-e2e/seatunnel-transforms-v2-e2e-part-2/src/test/resources/json_path_transform/json_path_array_map.conf new file mode 100644 index 00000000000..d2bf58dd00e --- /dev/null +++ b/seatunnel-e2e/seatunnel-transforms-v2-e2e/seatunnel-transforms-v2-e2e-part-2/src/test/resources/json_path_transform/json_path_array_map.conf @@ -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. +# + +###### +###### This config file is a demonstration of streaming processing in seatunnel config +###### + +env { + job.mode = "BATCH" +} + +source { + FakeSource { + plugin_output = "fake" + row.num = 100 + string.fake.mode = "template" + string.template=["{"data":{"c_map_array":[{"c_string":"this is a string","c_boolean": "true","c_integer": "42"},{"c_string":"this is a string","c_boolean": "true","c_integer": "42"}]}}"] + schema = { + fields { + data = "string" + } + } + } +} + +transform { + JsonPath { + plugin_input = "fake" + plugin_output = "fake1" + columns = [ + { + "src_field" = "data" + "path" = "$.data.c_map_array" + "dest_field" = "c_map_array_1" + "dest_type" = "array>" + } + ] + } + Sql { + plugin_input = "fake1" + plugin_output = "fake2" + query = "select c_map_array_1 from dual" + } +} + +sink { + Assert { + plugin_input = "fake2" + rules = + { + row_rules = [ + { + rule_type = MIN_ROW + rule_value = 100 + } + ], + field_rules = [ + { + field_name = c_map_array_1 + field_type = "array>" + field_value = [ + { + rule_type = NOT_NULL + equals_to = [{c_string=this is a string, c_boolean=true, c_integer=42}, {c_string=this is a string, c_boolean=true, c_integer=42}] + } + ] + } + ] + } + } +} \ No newline at end of file