diff --git a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/Column.java b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/Column.java
index 01d2a2874ce..393049162d1 100644
--- a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/Column.java
+++ b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/Column.java
@@ -34,11 +34,11 @@ public abstract class Column {
/**
* Data type of the column.
*/
- protected final DataType dataType;
+ protected final DataType> dataType;
protected final String comment;
- private Column(String name, DataType dataType, String comment) {
+ private Column(String name, DataType> dataType, String comment) {
this.name = name;
this.dataType = dataType;
this.comment = comment;
@@ -47,7 +47,7 @@ private Column(String name, DataType dataType, String comment) {
/**
* Creates a regular table column that represents physical data.
*/
- public static PhysicalColumn physical(String name, DataType dataType) {
+ public static PhysicalColumn physical(String name, DataType> dataType) {
return new PhysicalColumn(name, dataType);
}
@@ -58,7 +58,7 @@ public static PhysicalColumn physical(String name, DataType dataType) {
*
Allows to specify whether the column is virtual or not.
*/
public static MetadataColumn metadata(
- String name, DataType dataType, String metadataKey) {
+ String name, DataType> dataType, String metadataKey) {
return new MetadataColumn(name, dataType, metadataKey);
}
@@ -76,7 +76,7 @@ public static MetadataColumn metadata(
/**
* Returns the data type of this column.
*/
- public DataType getDataType() {
+ public DataType> getDataType() {
return this.dataType;
}
@@ -97,7 +97,7 @@ public Optional getComment() {
/**
* Returns a copy of the column with a replaced {@link DataType}.
*/
- public abstract Column copy(DataType newType);
+ public abstract Column copy(DataType> newType);
@Override
public boolean equals(Object o) {
@@ -127,11 +127,11 @@ public int hashCode() {
*/
public static final class PhysicalColumn extends Column {
- private PhysicalColumn(String name, DataType dataType) {
+ private PhysicalColumn(String name, DataType> dataType) {
this(name, dataType, null);
}
- private PhysicalColumn(String name, DataType dataType, String comment) {
+ private PhysicalColumn(String name, DataType> dataType, String comment) {
super(name, dataType, comment);
}
@@ -149,7 +149,7 @@ public boolean isPhysical() {
}
@Override
- public Column copy(DataType newDataType) {
+ public Column copy(DataType> newDataType) {
return new PhysicalColumn(name, newDataType, comment);
}
}
@@ -162,13 +162,13 @@ public static final class MetadataColumn extends Column {
private final String metadataKey;
private MetadataColumn(
- String name, DataType dataType, String metadataKey) {
+ String name, DataType> dataType, String metadataKey) {
this(name, dataType, metadataKey, null);
}
private MetadataColumn(
String name,
- DataType dataType,
+ DataType> dataType,
String metadataKey,
String comment) {
super(name, dataType, comment);
@@ -193,7 +193,7 @@ public boolean isPhysical() {
}
@Override
- public Column copy(DataType newDataType) {
+ public Column copy(DataType> newDataType) {
return new MetadataColumn(name, newDataType, metadataKey, comment);
}
diff --git a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/connector/SupportReadingMetadata.java b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/connector/SupportReadingMetadata.java
index 3fc90e17324..661885807f7 100644
--- a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/connector/SupportReadingMetadata.java
+++ b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/connector/SupportReadingMetadata.java
@@ -28,7 +28,7 @@
*/
public interface SupportReadingMetadata {
- Map listReadableMetadata(CatalogTable catalogTable);
+ Map> listReadableMetadata(CatalogTable catalogTable);
- void applyReadableMetadata(CatalogTable catalogTable, List metadataKeys, DataType dataType);
+ void applyReadableMetadata(CatalogTable catalogTable, List metadataKeys, DataType> dataType);
}
diff --git a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/ArrayType.java b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/ArrayType.java
new file mode 100644
index 00000000000..1e24cd25159
--- /dev/null
+++ b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/ArrayType.java
@@ -0,0 +1,15 @@
+package org.apache.seatunnel.api.table.type;
+
+public class ArrayType implements DataType {
+
+ private final BasicType elementType;
+
+ public ArrayType(BasicType elementType) {
+ this.elementType = elementType;
+ }
+
+ public BasicType getElementType() {
+ return elementType;
+ }
+
+}
diff --git a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/BasicType.java b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/BasicType.java
index 13489f228fc..c2834f7e048 100644
--- a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/BasicType.java
+++ b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/BasicType.java
@@ -17,6 +17,9 @@
package org.apache.seatunnel.api.table.type;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.time.Instant;
import java.util.Date;
public class BasicType implements DataType {
@@ -29,19 +32,50 @@ public class BasicType implements DataType {
public static final BasicType LONG = new BasicType<>(Long.class);
public static final BasicType FLOAT = new BasicType<>(Float.class);
public static final BasicType BYTE = new BasicType<>(Byte.class);
+ public static final BasicType SHORT = new BasicType<>(Short.class);
+ public static final BasicType CHARACTER = new BasicType<>(Character.class);
+ public static final BasicType BIG_INTEGER = new BasicType<>(BigInteger.class);
+ public static final BasicType BIG_DECIMAL = new BasicType<>(BigDecimal.class);
+ public static final BasicType INSTANT = new BasicType<>(Instant.class);
public static final BasicType NULL = new BasicType<>(Void.class);
- private final Class typeClass;
+ /**
+ * The physical type class.
+ */
+ private final Class physicalTypeClass;
- public BasicType(Class typeClass) {
- if (typeClass == null) {
- throw new IllegalArgumentException("typeClass cannot be null");
+ public BasicType(Class physicalTypeClass) {
+ if (physicalTypeClass == null) {
+ throw new IllegalArgumentException("physicalTypeClass cannot be null");
}
- this.typeClass = typeClass;
+ this.physicalTypeClass = physicalTypeClass;
+ }
+
+ public Class getPhysicalTypeClass() {
+ return this.physicalTypeClass;
+ }
+
+ @Override
+ public int hashCode() {
+ return this.physicalTypeClass.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ BasicType> other = (BasicType>) obj;
+ return this.physicalTypeClass.equals(other.physicalTypeClass);
}
@Override
- public Class getTypeClass() {
- return this.typeClass;
+ public String toString() {
+ return "BasicType{" +
+ "physicalTypeClass=" + physicalTypeClass +
+ '}';
}
}
diff --git a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/DataType.java b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/DataType.java
index 0c65f471013..2183ad18134 100644
--- a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/DataType.java
+++ b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/DataType.java
@@ -18,15 +18,9 @@
package org.apache.seatunnel.api.table.type;
/**
- * Data type of column in SeaTunnel.
+ * Logic data type of column in SeaTunnel.
*/
public interface DataType {
- /**
- * The type class.
- *
- * @return the type class.
- */
- Class getTypeClass();
}
diff --git a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/EnumType.java b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/EnumType.java
new file mode 100644
index 00000000000..9b4f851744a
--- /dev/null
+++ b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/EnumType.java
@@ -0,0 +1,13 @@
+package org.apache.seatunnel.api.table.type;
+
+public class EnumType> implements DataType {
+ private final Class enumClass;
+
+ public EnumType(Class enumClass) {
+ this.enumClass = enumClass;
+ }
+
+ public Class getEnumClass() {
+ return enumClass;
+ }
+}
diff --git a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/ListType.java b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/ListType.java
index 54ccad0b4bf..41c570047f9 100644
--- a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/ListType.java
+++ b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/ListType.java
@@ -19,15 +19,13 @@
public class ListType implements DataType {
- // todo: use DataType?
- private final Class typeClass;
+ private final DataType elementType;
- public ListType(Class typeClass) {
- this.typeClass = typeClass;
+ public ListType(DataType elementType) {
+ this.elementType = elementType;
}
- @Override
- public Class getTypeClass() {
- return typeClass;
+ public DataType getElementType() {
+ return elementType;
}
}
diff --git a/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/MapType.java b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/MapType.java
new file mode 100644
index 00000000000..6c8c24b78de
--- /dev/null
+++ b/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/MapType.java
@@ -0,0 +1,29 @@
+package org.apache.seatunnel.api.table.type;
+
+import java.util.Map;
+
+public class MapType implements DataType