snuyanzin commented on code in PR #29330:
URL: https://github.com/apache/flink/pull/29330#discussion_r4132768329


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/calcite/SqlTypeUtilTest.java:
##########
@@ -42,14 +54,35 @@ class SqlTypeUtilTest {
      */
     @Test
     void testConvertRowTypeToSpecAndUnparse() {
-        FlinkTypeFactory typeFactory =
-                new FlinkTypeFactory(
-                        Thread.currentThread().getContextClassLoader(), 
FlinkTypeSystem.INSTANCE);
         RowType rowType =
                 RowType.of(
                         new LogicalType[] {new IntType(), new VarCharType(1)},
                         new String[] {"a", "b"});
-        RelDataType relDataType = 
LogicalRelDataTypeConverter.toRelDataType(rowType, typeFactory);
+        assertThat(convertToSpecAndUnparse(rowType))
+                .hasToString("ROW(\"a\" INTEGER, \"b\" VARCHAR(1) CHARACTER 
SET \"UTF-16LE\")");
+    }
+
+    @ParameterizedTest(name = "{0}")
+    @MethodSource("variantTypes")
+    void testConvertTypeToSpecAndUnparse(DataType dataType, String expected) {
+        
assertThat(convertToSpecAndUnparse(dataType.getLogicalType())).isEqualTo(expected);
+    }
+
+    private static Stream<Arguments> variantTypes() {
+        return Stream.of(
+                Arguments.of(VARIANT(), "VARIANT"),
+                Arguments.of(VARIANT().notNull(), "VARIANT"),
+                Arguments.of(ARRAY(VARIANT()), "VARIANT ARRAY"),
+                Arguments.of(ROW(FIELD("v", VARIANT())), "ROW(\"v\" VARIANT)"),
+                Arguments.of(MAP(INT(), VARIANT()), "MAP< INTEGER, VARIANT 
>"));
+    }
+
+    private static String convertToSpecAndUnparse(LogicalType logicalType) {
+        FlinkTypeFactory typeFactory =
+                new FlinkTypeFactory(
+                        Thread.currentThread().getContextClassLoader(), 
FlinkTypeSystem.INSTANCE);
+        RelDataType relDataType =
+                LogicalRelDataTypeConverter.toRelDataType(logicalType, 
typeFactory);

Review Comment:
   nit: can we reuse typefactory and SqlPrettyWriter?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to