You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by wa...@apache.org on 2023/09/20 07:48:54 UTC

[seatunnel] branch dev updated: [Improve] Remove CatalogTable field in CatalogTableUtil (#5521)

This is an automated email from the ASF dual-hosted git repository.

wanghailin pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/seatunnel.git


The following commit(s) were added to refs/heads/dev by this push:
     new 2887424681 [Improve] Remove CatalogTable field in CatalogTableUtil (#5521)
2887424681 is described below

commit 28874246813d3e5a59b902cd97cdd31d71afb0d3
Author: Jia Fan <fa...@qq.com>
AuthorDate: Wed Sep 20 15:48:48 2023 +0800

    [Improve] Remove CatalogTable field in CatalogTableUtil (#5521)
---
 .../seatunnel/api/table/catalog/CatalogTable.java  |  6 ++++
 .../api/table/catalog/CatalogTableUtil.java        | 32 +++++++---------------
 2 files changed, 16 insertions(+), 22 deletions(-)

diff --git a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/CatalogTable.java b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/CatalogTable.java
index 1be6de0284..5b1f124863 100644
--- a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/CatalogTable.java
+++ b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/CatalogTable.java
@@ -17,6 +17,8 @@
 
 package org.apache.seatunnel.api.table.catalog;
 
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+
 import java.io.Serializable;
 import java.util.List;
 import java.util.Map;
@@ -91,6 +93,10 @@ public final class CatalogTable implements Serializable {
         return tableSchema;
     }
 
+    public SeaTunnelRowType getSeaTunnelRowType() {
+        return tableSchema.toPhysicalRowDataType();
+    }
+
     public Map<String, String> getOptions() {
         return options;
     }
diff --git a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/CatalogTableUtil.java b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/CatalogTableUtil.java
index 07c3473bff..8439222b53 100644
--- a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/CatalogTableUtil.java
+++ b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/CatalogTableUtil.java
@@ -42,7 +42,6 @@ import org.apache.seatunnel.common.config.CheckResult;
 import org.apache.seatunnel.common.utils.JsonUtils;
 import org.apache.seatunnel.common.utils.SeaTunnelException;
 
-import lombok.Getter;
 import lombok.extern.slf4j.Slf4j;
 
 import java.io.Serializable;
@@ -70,12 +69,6 @@ public class CatalogTableUtil implements Serializable {
             new SeaTunnelRowType(
                     new String[] {"content"}, new SeaTunnelDataType<?>[] {BasicType.STRING_TYPE});
 
-    @Getter private final CatalogTable catalogTable;
-
-    private CatalogTableUtil(CatalogTable catalogTable) {
-        this.catalogTable = catalogTable;
-    }
-
     @Deprecated
     public static CatalogTable getCatalogTable(String tableName, SeaTunnelRowType rowType) {
         TableSchema.Builder schemaBuilder = TableSchema.builder();
@@ -108,7 +101,7 @@ public class CatalogTableUtil implements Serializable {
         // Highest priority: specified schema
         Map<String, String> schemaMap = readonlyConfig.get(CatalogTableUtil.SCHEMA);
         if (schemaMap != null && schemaMap.size() > 0) {
-            CatalogTable catalogTable = CatalogTableUtil.buildWithConfig(config).getCatalogTable();
+            CatalogTable catalogTable = CatalogTableUtil.buildWithConfig(config);
             return Collections.singletonList(catalogTable);
         }
 
@@ -158,7 +151,7 @@ public class CatalogTableUtil implements Serializable {
             if (schemaMap.isEmpty()) {
                 throw new SeaTunnelException("Schema config can not be empty");
             }
-            CatalogTable catalogTable = CatalogTableUtil.buildWithConfig(config).getCatalogTable();
+            CatalogTable catalogTable = CatalogTableUtil.buildWithConfig(config);
             return Collections.singletonList(catalogTable);
         }
 
@@ -194,31 +187,26 @@ public class CatalogTableUtil implements Serializable {
                                                 factoryId)));
     }
 
-    public static CatalogTableUtil buildWithConfig(Config config) {
+    public static CatalogTable buildWithConfig(Config config) {
         CheckResult checkResult = CheckConfigUtil.checkAllExists(config, "schema");
         if (!checkResult.isSuccess()) {
             throw new RuntimeException(
                     "Schema config need option [schema], please correct your config first");
         }
         TableSchema tableSchema = parseTableSchema(config.getConfig("schema"));
-        return new CatalogTableUtil(
-                CatalogTable.of(
-                        // TODO: other table info
-                        TableIdentifier.of("", "", ""),
-                        tableSchema,
-                        new HashMap<>(),
-                        new ArrayList<>(),
-                        ""));
+        return CatalogTable.of(
+                // TODO: other table info
+                TableIdentifier.of("", "", ""),
+                tableSchema,
+                new HashMap<>(),
+                new ArrayList<>(),
+                "");
     }
 
     public static SeaTunnelRowType buildSimpleTextSchema() {
         return SIMPLE_SCHEMA;
     }
 
-    public SeaTunnelRowType getSeaTunnelRowType() {
-        return catalogTable.getTableSchema().toPhysicalRowDataType();
-    }
-
     public static SeaTunnelDataType<?> parseDataType(String columnStr) {
         SqlType sqlType = null;
         try {