Hisoka-X commented on code in PR #6425: URL: https://github.com/apache/seatunnel/pull/6425#discussion_r1560397506
########## seatunnel-connectors-v2/connector-elasticsearch/src/test/java/org/apache/seatunnel/connectors/seatunnel/elasticsearch/ElasticsearchSourceTest.java: ########## @@ -0,0 +1,64 @@ +/* + * 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. + */ + +package org.apache.seatunnel.connectors.seatunnel.elasticsearch; + +import org.apache.seatunnel.api.common.PrepareFailException; +import org.apache.seatunnel.api.table.type.BasicType; +import org.apache.seatunnel.api.table.type.SeaTunnelDataType; +import org.apache.seatunnel.api.table.type.SeaTunnelRowType; +import org.apache.seatunnel.connectors.seatunnel.elasticsearch.catalog.ElasticSearchDataTypeConvertor; + +import org.apache.commons.collections4.CollectionUtils; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import com.google.common.collect.Lists; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ElasticsearchSourceTest { + @Test + public void testPrepareWithEmptySource() throws PrepareFailException { Review Comment: I think this test case useless, because it just copy same code from source code. If source code changed, this test case would not work fine anymore. I suggest refactor these code in source to a single method. Then invoke it in the test case to make sure it work fine. ########## seatunnel-connectors-v2/connector-elasticsearch/src/main/java/org/apache/seatunnel/connectors/seatunnel/elasticsearch/client/EsRestClient.java: ########## @@ -599,6 +618,14 @@ private static Map<String, BasicTypeDefine<EsType>> getFieldTypeMappingFromPrope typeDefine.nativeType( new EsType(OBJECT, (Map) subFieldTypeInfoMap)); allElasticSearchFieldTypeInfoMap.put(fieldName, typeDefine.build()); + } else { + // For map types + BasicTypeDefine.BasicTypeDefineBuilder<EsType> typeDefine = + BasicTypeDefine.<EsType>builder() + .name(fieldName) + .columnType("text") + .dataType("text"); + allElasticSearchFieldTypeInfoMap.put(fieldName, typeDefine.build()); Review Comment: Quick quesiton: how to create a map type in elasticsearch? -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
