Skip to content

Commit

Permalink
[Feature-3532][admin] Supports viewing schema of SQL tables with comp…
Browse files Browse the repository at this point in the history
…lex data types in catalog (#3640)

Co-authored-by: suxinshuo <[email protected]>
  • Loading branch information
suxinshuo and suxinshuo authored Jul 18, 2024
1 parent 9dc2fc6 commit 5ed1fc6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,10 @@ public static List<Column> getColumnList(
column.setScale(((DecimalType) logicalType).getScale());
}

for (ColumnType columnType : ColumnType.values()) {
if (columnType
.getJavaType()
.equals(flinkColumn
.getDataType()
.getConversionClass()
.getName())) {
column.setJavaType(columnType);
break;
}
}
// FlinkColumn flinkColumn = FlinkColumn.build(i,
// column.getName(), column.getDataType().getConversionClass().getName(),
// isPrimaryKey.get(), column.getDataType().getLogicalType().isNullable(),
// column.explainExtras().orElse(""), "", column.getComment().orElse(""));

String dataTypeName =
flinkColumn.getDataType().getConversionClass().getName();
ColumnType columnType = ColumnType.getByJavaType(dataTypeName);
column.setJavaType(columnType);
columns.add(column);
}
});
Expand Down
19 changes: 19 additions & 0 deletions dinky-common/src/main/java/org/dinky/data/enums/ColumnType.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@

package org.dinky.data.enums;

import java.util.Arrays;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonValue;
import com.google.common.collect.Maps;

/**
* ColumnType
Expand Down Expand Up @@ -61,6 +65,17 @@ public enum ColumnType {
private final String javaType;
private final String flinkType;

/**
* JavaType -> ColumnType
*/
private static final Map<String, ColumnType> JAVA_COL_TYPE_MAP = Maps.newHashMap();

static {
Arrays.stream(ColumnType.values()).forEach(columnType -> {
JAVA_COL_TYPE_MAP.put(columnType.getJavaType(), columnType);
});
}

ColumnType(String javaType, String flinkType) {
this.javaType = javaType;
this.flinkType = flinkType;
Expand All @@ -74,4 +89,8 @@ public String getJavaType() {
public String getFlinkType() {
return flinkType;
}

public static ColumnType getByJavaType(String javaType) {
return JAVA_COL_TYPE_MAP.getOrDefault(javaType, STRING);
}
}

0 comments on commit 5ed1fc6

Please sign in to comment.