diff --git a/src/main/java/org/apache/paimon/trino/TrinoTypeUtils.java b/src/main/java/org/apache/paimon/trino/TrinoTypeUtils.java index defdd12c..3681e558 100644 --- a/src/main/java/org/apache/paimon/trino/TrinoTypeUtils.java +++ b/src/main/java/org/apache/paimon/trino/TrinoTypeUtils.java @@ -75,6 +75,9 @@ public Type visit(CharType charType) { @Override public Type visit(VarCharType varCharType) { + if (varCharType.getLength() == VarCharType.MAX_LENGTH) { + return VarcharType.createUnboundedVarcharType(); + } return VarcharType.createVarcharType( Math.min(VarcharType.MAX_LENGTH, varCharType.getLength())); } diff --git a/src/test/java/org/apache/paimon/trino/TestTrinoITCase.java b/src/test/java/org/apache/paimon/trino/TestTrinoITCase.java index 20df4419..a5287782 100644 --- a/src/test/java/org/apache/paimon/trino/TestTrinoITCase.java +++ b/src/test/java/org/apache/paimon/trino/TestTrinoITCase.java @@ -34,6 +34,7 @@ import org.apache.paimon.types.BigIntType; import org.apache.paimon.types.CharType; import org.apache.paimon.types.DataField; +import org.apache.paimon.types.DataTypes; import org.apache.paimon.types.IntType; import org.apache.paimon.types.MapType; import org.apache.paimon.types.RowKind; @@ -91,7 +92,7 @@ protected QueryRunner createQueryRunner() throws Exception { RowType rowType = new RowType( Arrays.asList( - new DataField(0, "pt", new VarCharType()), + new DataField(0, "pt", DataTypes.STRING()), new DataField(1, "a", new IntType()), new DataField(2, "b", new BigIntType()), new DataField(3, "c", new BigIntType()), @@ -199,6 +200,18 @@ public void testGroupByWithCast() { .isEqualTo("[[1, 1, 3, 3], [2, 3, 3, 3]]"); } + @Test + public void testShowCreateTable() { + assertThat(sql("SHOW CREATE TABLE paimon.default.t3")) + .isEqualTo("[[CREATE TABLE paimon.default.t3 (\n" + + " pt varchar,\n" + + " a integer,\n" + + " b bigint,\n" + + " c bigint,\n" + + " d integer\n" + + ")]]"); + } + private String sql(String sql) { MaterializedResult result = getQueryRunner().execute(sql); return result.getMaterializedRows().toString();