You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "zhangshenghang (via GitHub)" <gi...@apache.org> on 2024/08/21 12:17:19 UTC
[PR] [feature] support typesense connector [seatunnel]
zhangshenghang opened a new pull request, #7450:
URL: https://github.com/apache/seatunnel/pull/7450
### Purpose of this pull request
#7191
Support Typesense Connector
@hailin0
--
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-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [feature] [Connector-V2][Typesense]support typesense connector [seatunnel]
Posted by "hailin0 (via GitHub)" <gi...@apache.org>.
hailin0 commented on PR #7450:
URL: https://github.com/apache/seatunnel/pull/7450#issuecomment-2303622763
good pr
--
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-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [feature] [Connector-V2][Typesense]support typesense connector [seatunnel]
Posted by "zhangshenghang (via GitHub)" <gi...@apache.org>.
zhangshenghang commented on PR #7450:
URL: https://github.com/apache/seatunnel/pull/7450#issuecomment-2312574582
> Please add label too.
>
> https://github.com/apache/seatunnel/blob/c6f627fa38d29f83bccb3e1fb86e8962b64dad4e/.github/workflows/labeler/label-scope-conf.yml#L255
already added
--
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-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [feature] [Connector-V2][Typesense]support typesense connector [seatunnel]
Posted by "zhangshenghang (via GitHub)" <gi...@apache.org>.
zhangshenghang commented on code in PR #7450:
URL: https://github.com/apache/seatunnel/pull/7450#discussion_r1724987541
##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-typesense-e2e/src/test/java/org/apache/seatunnel/e2e/connector/typesense/TypesenseIT.java:
##########
@@ -0,0 +1,280 @@
+/*
+ * 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.e2e.connector.typesense;
+
+import org.apache.seatunnel.shade.com.fasterxml.jackson.core.JsonProcessingException;
+import org.apache.seatunnel.shade.com.fasterxml.jackson.databind.ObjectMapper;
+
+import org.apache.seatunnel.connectors.seatunnel.typesense.client.TypesenseClient;
+import org.apache.seatunnel.e2e.common.TestResource;
+import org.apache.seatunnel.e2e.common.TestSuiteBase;
+import org.apache.seatunnel.e2e.common.container.EngineType;
+import org.apache.seatunnel.e2e.common.container.TestContainer;
+import org.apache.seatunnel.e2e.common.container.TestContainerId;
+import org.apache.seatunnel.e2e.common.junit.DisabledOnContainer;
+
+import org.apache.commons.lang3.RandomUtils;
+
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.TestTemplate;
+import org.testcontainers.containers.Container;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.lifecycle.Startables;
+import org.testcontainers.utility.DockerLoggerFactory;
+import org.typesense.api.FieldTypes;
+import org.typesense.model.Field;
+
+import com.google.common.collect.Lists;
+import lombok.extern.slf4j.Slf4j;
+
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Stream;
+
+@DisabledOnContainer(
+ value = {
+ TestContainerId.FLINK_1_13,
+ TestContainerId.FLINK_1_14,
+ TestContainerId.FLINK_1_15
+ },
+ type = {EngineType.SEATUNNEL, EngineType.SPARK},
+ disabledReason = "Test only one engine for first change")
Review Comment:
> Disabled all engine?
sry , I blocked it during testing and forgot to restore it. I am now deleting it
--
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-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [feature] [Connector-V2][Typesense]support typesense connector [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on PR #7450:
URL: https://github.com/apache/seatunnel/pull/7450#issuecomment-2301959221
Thanks @zhangshenghang !
--
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-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [feature] [Connector-V2][Typesense]support typesense connector [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #7450:
URL: https://github.com/apache/seatunnel/pull/7450#discussion_r1724984386
##########
seatunnel-e2e/seatunnel-connector-v2-e2e/connector-typesense-e2e/src/test/java/org/apache/seatunnel/e2e/connector/typesense/TypesenseIT.java:
##########
@@ -0,0 +1,280 @@
+/*
+ * 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.e2e.connector.typesense;
+
+import org.apache.seatunnel.shade.com.fasterxml.jackson.core.JsonProcessingException;
+import org.apache.seatunnel.shade.com.fasterxml.jackson.databind.ObjectMapper;
+
+import org.apache.seatunnel.connectors.seatunnel.typesense.client.TypesenseClient;
+import org.apache.seatunnel.e2e.common.TestResource;
+import org.apache.seatunnel.e2e.common.TestSuiteBase;
+import org.apache.seatunnel.e2e.common.container.EngineType;
+import org.apache.seatunnel.e2e.common.container.TestContainer;
+import org.apache.seatunnel.e2e.common.container.TestContainerId;
+import org.apache.seatunnel.e2e.common.junit.DisabledOnContainer;
+
+import org.apache.commons.lang3.RandomUtils;
+
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.TestTemplate;
+import org.testcontainers.containers.Container;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.output.Slf4jLogConsumer;
+import org.testcontainers.lifecycle.Startables;
+import org.testcontainers.utility.DockerLoggerFactory;
+import org.typesense.api.FieldTypes;
+import org.typesense.model.Field;
+
+import com.google.common.collect.Lists;
+import lombok.extern.slf4j.Slf4j;
+
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Stream;
+
+@DisabledOnContainer(
+ value = {
+ TestContainerId.FLINK_1_13,
+ TestContainerId.FLINK_1_14,
+ TestContainerId.FLINK_1_15
+ },
+ type = {EngineType.SEATUNNEL, EngineType.SPARK},
+ disabledReason = "Test only one engine for first change")
Review Comment:
Disabled all engine?
--
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-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support typesense connector [seatunnel]
Posted by "hailin0 (via GitHub)" <gi...@apache.org>.
hailin0 merged PR #7450:
URL: https://github.com/apache/seatunnel/pull/7450
--
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-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support typesense connector [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #7450:
URL: https://github.com/apache/seatunnel/pull/7450#discussion_r1734465030
##########
seatunnel-connectors-v2/connector-typesense/src/main/java/org/apache/seatunnel/connectors/seatunnel/typesense/catalog/TypesenseTypeConverter.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.typesense.catalog;
+
+import org.apache.seatunnel.api.table.catalog.Column;
+import org.apache.seatunnel.api.table.catalog.PhysicalColumn;
+import org.apache.seatunnel.api.table.converter.BasicTypeConverter;
+import org.apache.seatunnel.api.table.converter.BasicTypeDefine;
+import org.apache.seatunnel.api.table.converter.TypeConverter;
+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.typesense.client.TypesenseType;
+
+import com.google.auto.service.AutoService;
+
+import java.util.Map;
+
+import static org.apache.seatunnel.connectors.seatunnel.typesense.client.TypesenseType.INT32;
+import static org.apache.seatunnel.connectors.seatunnel.typesense.client.TypesenseType.INT64;
+
+@AutoService(TypeConverter.class)
+public class TypesenseTypeConverter implements BasicTypeConverter<BasicTypeDefine<TypesenseType>> {
+ public static final TypesenseTypeConverter INSTANCE = new TypesenseTypeConverter();
+
+ @Override
+ public String identifier() {
+ return "Typesense";
+ }
+
+ @Override
+ public Column convert(BasicTypeDefine<TypesenseType> typeDefine) {
+ PhysicalColumn.PhysicalColumnBuilder builder =
+ PhysicalColumn.builder()
+ .name(typeDefine.getName())
+ .sourceType(typeDefine.getColumnType())
+ .nullable(typeDefine.isNullable())
+ .defaultValue(typeDefine.getDefaultValue())
+ .comment(typeDefine.getComment());
+ String type = typeDefine.getDataType().toLowerCase();
+ switch (type) {
+ case INT32:
+ builder.dataType(BasicType.INT_TYPE);
+ break;
+ case INT64:
+ builder.dataType(BasicType.LONG_TYPE);
+ break;
+ case TypesenseType.FLOAT:
+ builder.dataType(BasicType.FLOAT_TYPE);
+ break;
+ case TypesenseType.BOOL:
+ builder.dataType(BasicType.BOOLEAN_TYPE);
+ break;
+ case TypesenseType.OBJET:
+ Map<String, BasicTypeDefine<TypesenseType>> typeInfo =
+ (Map) typeDefine.getNativeType().getOptions();
+ SeaTunnelRowType object =
+ new SeaTunnelRowType(
+ typeInfo.keySet().toArray(new String[0]),
+ typeInfo.values().stream()
+ .map(this::convert)
+ .map(Column::getDataType)
+ .toArray(SeaTunnelDataType<?>[]::new));
+ builder.dataType(object);
+ break;
+ case TypesenseType.STRING:
+ case TypesenseType.IMAGE:
+ default:
+ builder.dataType(BasicType.STRING_TYPE);
+ break;
+ }
+ return builder.build();
+ }
+
+ @Override
+ public BasicTypeDefine<TypesenseType> reconvert(Column column) {
+ return null;
Review Comment:
throw new UnsupportedException?
--
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-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature][Connector-V2] Support typesense connector [seatunnel]
Posted by "zhangshenghang (via GitHub)" <gi...@apache.org>.
zhangshenghang commented on code in PR #7450:
URL: https://github.com/apache/seatunnel/pull/7450#discussion_r1734673486
##########
seatunnel-connectors-v2/connector-typesense/src/main/java/org/apache/seatunnel/connectors/seatunnel/typesense/catalog/TypesenseTypeConverter.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.typesense.catalog;
+
+import org.apache.seatunnel.api.table.catalog.Column;
+import org.apache.seatunnel.api.table.catalog.PhysicalColumn;
+import org.apache.seatunnel.api.table.converter.BasicTypeConverter;
+import org.apache.seatunnel.api.table.converter.BasicTypeDefine;
+import org.apache.seatunnel.api.table.converter.TypeConverter;
+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.typesense.client.TypesenseType;
+
+import com.google.auto.service.AutoService;
+
+import java.util.Map;
+
+import static org.apache.seatunnel.connectors.seatunnel.typesense.client.TypesenseType.INT32;
+import static org.apache.seatunnel.connectors.seatunnel.typesense.client.TypesenseType.INT64;
+
+@AutoService(TypeConverter.class)
+public class TypesenseTypeConverter implements BasicTypeConverter<BasicTypeDefine<TypesenseType>> {
+ public static final TypesenseTypeConverter INSTANCE = new TypesenseTypeConverter();
+
+ @Override
+ public String identifier() {
+ return "Typesense";
+ }
+
+ @Override
+ public Column convert(BasicTypeDefine<TypesenseType> typeDefine) {
+ PhysicalColumn.PhysicalColumnBuilder builder =
+ PhysicalColumn.builder()
+ .name(typeDefine.getName())
+ .sourceType(typeDefine.getColumnType())
+ .nullable(typeDefine.isNullable())
+ .defaultValue(typeDefine.getDefaultValue())
+ .comment(typeDefine.getComment());
+ String type = typeDefine.getDataType().toLowerCase();
+ switch (type) {
+ case INT32:
+ builder.dataType(BasicType.INT_TYPE);
+ break;
+ case INT64:
+ builder.dataType(BasicType.LONG_TYPE);
+ break;
+ case TypesenseType.FLOAT:
+ builder.dataType(BasicType.FLOAT_TYPE);
+ break;
+ case TypesenseType.BOOL:
+ builder.dataType(BasicType.BOOLEAN_TYPE);
+ break;
+ case TypesenseType.OBJET:
+ Map<String, BasicTypeDefine<TypesenseType>> typeInfo =
+ (Map) typeDefine.getNativeType().getOptions();
+ SeaTunnelRowType object =
+ new SeaTunnelRowType(
+ typeInfo.keySet().toArray(new String[0]),
+ typeInfo.values().stream()
+ .map(this::convert)
+ .map(Column::getDataType)
+ .toArray(SeaTunnelDataType<?>[]::new));
+ builder.dataType(object);
+ break;
+ case TypesenseType.STRING:
+ case TypesenseType.IMAGE:
+ default:
+ builder.dataType(BasicType.STRING_TYPE);
+ break;
+ }
+ return builder.build();
+ }
+
+ @Override
+ public BasicTypeDefine<TypesenseType> reconvert(Column column) {
+ return null;
Review Comment:
modify after:
```java
@Override
public BasicTypeDefine<TypesenseType> reconvert(Column column) {
throw new UnsupportedOperationException("Unsupported operation");
}
```
--
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-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [feature] [Connector-V2][Typesense]support typesense connector [seatunnel]
Posted by "zhangshenghang (via GitHub)" <gi...@apache.org>.
zhangshenghang commented on code in PR #7450:
URL: https://github.com/apache/seatunnel/pull/7450#discussion_r1732858121
##########
seatunnel-connectors-v2/connector-typesense/src/main/java/org/apache/seatunnel/connectors/seatunnel/typesense/catalog/TypesenseTypeConverter.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.typesense.catalog;
+
+import org.apache.seatunnel.api.table.catalog.Column;
+import org.apache.seatunnel.api.table.catalog.PhysicalColumn;
+import org.apache.seatunnel.api.table.converter.BasicTypeConverter;
+import org.apache.seatunnel.api.table.converter.BasicTypeDefine;
+import org.apache.seatunnel.api.table.converter.TypeConverter;
+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.typesense.client.TypesenseType;
+
+import com.google.auto.service.AutoService;
+
+import java.util.Map;
+
+import static org.apache.seatunnel.connectors.seatunnel.typesense.client.TypesenseType.INT32;
+import static org.apache.seatunnel.connectors.seatunnel.typesense.client.TypesenseType.INT64;
+
+@AutoService(TypeConverter.class)
+public class TypesenseTypeConverter implements BasicTypeConverter<BasicTypeDefine<TypesenseType>> {
+ public static final TypesenseTypeConverter INSTANCE = new TypesenseTypeConverter();
+
+ @Override
+ public String identifier() {
+ return "Typesense";
+ }
+
+ @Override
+ public Column convert(BasicTypeDefine<TypesenseType> typeDefine) {
+ PhysicalColumn.PhysicalColumnBuilder builder =
+ PhysicalColumn.builder()
+ .name(typeDefine.getName())
+ .sourceType(typeDefine.getColumnType())
+ .nullable(typeDefine.isNullable())
+ .defaultValue(typeDefine.getDefaultValue())
+ .comment(typeDefine.getComment());
+ String type = typeDefine.getDataType().toLowerCase();
+ switch (type) {
+ case INT32:
+ builder.dataType(BasicType.INT_TYPE);
+ break;
+ case INT64:
+ builder.dataType(BasicType.LONG_TYPE);
+ break;
+ case TypesenseType.FLOAT:
+ builder.dataType(BasicType.FLOAT_TYPE);
+ break;
+ case TypesenseType.BOOL:
+ builder.dataType(BasicType.BOOLEAN_TYPE);
+ break;
+ case TypesenseType.OBJET:
+ Map<String, BasicTypeDefine<TypesenseType>> typeInfo =
+ (Map) typeDefine.getNativeType().getOptions();
+ SeaTunnelRowType object =
+ new SeaTunnelRowType(
+ typeInfo.keySet().toArray(new String[0]),
+ typeInfo.values().stream()
+ .map(this::convert)
+ .map(Column::getDataType)
+ .toArray(SeaTunnelDataType<?>[]::new));
+ builder.dataType(object);
+ break;
+ case TypesenseType.STRING:
+ case TypesenseType.IMAGE:
+ default:
+ builder.dataType(BasicType.STRING_TYPE);
+ break;
+ }
+ return builder.build();
+ }
+
+ @Override
+ public BasicTypeDefine<TypesenseType> reconvert(Column column) {
+ return null;
Review Comment:
@Hisoka-X
This method is currently not used in the code. Do I still need to write in this situation? Do you have any good suggestions.
--
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-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [feature] [Connector-V2][Typesense]support typesense connector [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #7450:
URL: https://github.com/apache/seatunnel/pull/7450#discussion_r1732303595
##########
seatunnel-connectors-v2/connector-typesense/src/main/java/org/apache/seatunnel/connectors/seatunnel/typesense/catalog/TypesenseTypeConverter.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.typesense.catalog;
+
+import org.apache.seatunnel.api.table.catalog.Column;
+import org.apache.seatunnel.api.table.catalog.PhysicalColumn;
+import org.apache.seatunnel.api.table.converter.BasicTypeConverter;
+import org.apache.seatunnel.api.table.converter.BasicTypeDefine;
+import org.apache.seatunnel.api.table.converter.TypeConverter;
+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.typesense.client.TypesenseType;
+
+import com.google.auto.service.AutoService;
+
+import java.util.Map;
+
+import static org.apache.seatunnel.connectors.seatunnel.typesense.client.TypesenseType.INT32;
+import static org.apache.seatunnel.connectors.seatunnel.typesense.client.TypesenseType.INT64;
+
+@AutoService(TypeConverter.class)
+public class TypesenseTypeConverter implements BasicTypeConverter<BasicTypeDefine<TypesenseType>> {
+ public static final TypesenseTypeConverter INSTANCE = new TypesenseTypeConverter();
+
+ @Override
+ public String identifier() {
+ return "Typesense";
+ }
+
+ @Override
+ public Column convert(BasicTypeDefine<TypesenseType> typeDefine) {
+ PhysicalColumn.PhysicalColumnBuilder builder =
+ PhysicalColumn.builder()
+ .name(typeDefine.getName())
+ .sourceType(typeDefine.getColumnType())
+ .nullable(typeDefine.isNullable())
+ .defaultValue(typeDefine.getDefaultValue())
+ .comment(typeDefine.getComment());
+ String type = typeDefine.getDataType().toLowerCase();
+ switch (type) {
+ case INT32:
+ builder.dataType(BasicType.INT_TYPE);
+ break;
+ case INT64:
+ builder.dataType(BasicType.LONG_TYPE);
+ break;
+ case TypesenseType.FLOAT:
+ builder.dataType(BasicType.FLOAT_TYPE);
+ break;
+ case TypesenseType.BOOL:
+ builder.dataType(BasicType.BOOLEAN_TYPE);
+ break;
+ case TypesenseType.OBJET:
+ Map<String, BasicTypeDefine<TypesenseType>> typeInfo =
+ (Map) typeDefine.getNativeType().getOptions();
+ SeaTunnelRowType object =
+ new SeaTunnelRowType(
+ typeInfo.keySet().toArray(new String[0]),
+ typeInfo.values().stream()
+ .map(this::convert)
+ .map(Column::getDataType)
+ .toArray(SeaTunnelDataType<?>[]::new));
+ builder.dataType(object);
+ break;
+ case TypesenseType.STRING:
+ case TypesenseType.IMAGE:
+ default:
+ builder.dataType(BasicType.STRING_TYPE);
+ break;
+ }
+ return builder.build();
+ }
+
+ @Override
+ public BasicTypeDefine<TypesenseType> reconvert(Column column) {
+ return null;
Review Comment:
null ?
--
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-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [feature] [Connector-V2][Typesense]support typesense connector [seatunnel]
Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on PR #7450:
URL: https://github.com/apache/seatunnel/pull/7450#issuecomment-2311795183
Please add label too. https://github.com/apache/seatunnel/blob/c6f627fa38d29f83bccb3e1fb86e8962b64dad4e/.github/workflows/labeler/label-scope-conf.yml#L255
--
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-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org