twalthr commented on a change in pull request #9243: [FLINK-13335][sql-parser] 
Align the SQL CREATE TABLE DDL with FLIP-37
URL: https://github.com/apache/flink/pull/9243#discussion_r309181743
 
 

 ##########
 File path: 
flink-table/flink-sql-parser/src/test/java/org/apache/flink/sql/parser/FlinkDDLDataTypeTest.java
 ##########
 @@ -0,0 +1,441 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.sql.parser;
+
+import org.apache.flink.sql.parser.ddl.SqlCreateTable;
+import org.apache.flink.sql.parser.ddl.SqlTableColumn;
+import org.apache.flink.sql.parser.impl.FlinkSqlParserImpl;
+import org.apache.flink.sql.parser.validate.FlinkSqlConformance;
+
+import org.apache.calcite.avatica.util.Casing;
+import org.apache.calcite.avatica.util.Quoting;
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
+import org.apache.calcite.rel.type.RelDataTypeSystem;
+import org.apache.calcite.sql.SqlDataTypeSpec;
+import org.apache.calcite.sql.SqlDialect;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlNodeList;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.dialect.CalciteSqlDialect;
+import org.apache.calcite.sql.parser.SqlParseException;
+import org.apache.calcite.sql.parser.SqlParser;
+import org.apache.calcite.sql.parser.SqlParserTest;
+import org.apache.calcite.sql.parser.SqlParserUtil;
+import org.apache.calcite.sql.pretty.SqlPrettyWriter;
+import org.apache.calcite.sql.type.SqlTypeFactoryImpl;
+import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.calcite.test.SqlValidatorTestCase;
+import org.apache.calcite.util.Util;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import javax.annotation.Nullable;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests for all the sup[ported flink DDL data types.
+ */
+@RunWith(Parameterized.class)
+public class FlinkDDLDataTypeTest {
+       private FlinkSqlConformance conformance = FlinkSqlConformance.DEFAULT;
+       private static final RelDataTypeFactory TYPE_FACTORY =
+               new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
+       private static final Fixture FIXTURE = new Fixture(TYPE_FACTORY);
+       private static final String DDL_FORMAT = "create table t1 (\n" +
+               "  f0 %s\n" +
+               ") with (\n" +
+               "  k1 = 'v1'\n" +
+               ")";
+
+       @Parameterized.Parameters(name = "{index}: {0}")
+       public static List<TestItem> testData() {
+               return Arrays.asList(
+                       createTestItem("CHAR", nullable(FIXTURE.char1Type), 
"CHAR"),
+                       createTestItem("CHAR NOT NULL", FIXTURE.char1Type, 
"CHAR NOT NULL"),
+                       createTestItem("CHAR   NOT \t\nNULL", 
FIXTURE.char1Type, "CHAR NOT NULL"),
+                       createTestItem("char not null", FIXTURE.char1Type, 
"CHAR NOT NULL"),
+                       createTestItem("CHAR NULL", 
nullable(FIXTURE.char1Type), "CHAR"),
+                       createTestItem("CHAR(33)", 
nullable(FIXTURE.char33Type), "CHAR(33)"),
+                       createTestItem("VARCHAR", 
nullable(FIXTURE.varcharType), "VARCHAR"),
+                       createTestItem("VARCHAR(33)", 
nullable(FIXTURE.varchar33Type), "VARCHAR(33)"),
+                       createTestItem("STRING",
+                               
nullable(FIXTURE.createSqlType(SqlTypeName.VARCHAR, Integer.MAX_VALUE)), 
"STRING"),
 
 Review comment:
   Add this to `FIXTURE` as well?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to