You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/01/31 11:00:40 UTC

[GitHub] [flink] dawidwys commented on a change in pull request #10981: [hotfix][table] Convert FlinkCalciteSqlValidator to Java

dawidwys commented on a change in pull request #10981: [hotfix][table] Convert FlinkCalciteSqlValidator to Java
URL: https://github.com/apache/flink/pull/10981#discussion_r373424870
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/calcite/FlinkCalciteSqlValidator.java
 ##########
 @@ -0,0 +1,101 @@
+/*
+ * 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.table.planner.calcite;
+
+import org.apache.flink.annotation.Internal;
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.types.logical.DecimalType;
+
+import org.apache.calcite.rel.type.RelDataType;
+import org.apache.calcite.rel.type.RelDataTypeFactory;
+import org.apache.calcite.sql.JoinType;
+import org.apache.calcite.sql.SqlInsert;
+import org.apache.calcite.sql.SqlJoin;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlLiteral;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlOperatorTable;
+import org.apache.calcite.sql.SqlUtil;
+import org.apache.calcite.sql.validate.SqlConformanceEnum;
+import org.apache.calcite.sql.validate.SqlValidator;
+import org.apache.calcite.sql.validate.SqlValidatorCatalogReader;
+import org.apache.calcite.sql.validate.SqlValidatorImpl;
+import org.apache.calcite.sql.validate.SqlValidatorScope;
+import org.apache.calcite.util.Static;
+
+import java.math.BigDecimal;
+
+import static org.apache.calcite.sql.type.SqlTypeName.DECIMAL;
+import static org.apache.flink.table.planner.utils.ShortcutUtils.unwrapTypeFactory;
+
+/**
+ * Extends Calcite's {@link SqlValidator} by Flink-specific behavior.
+ */
+@Internal
+public final class FlinkCalciteSqlValidator extends SqlValidatorImpl {
+
+	public FlinkCalciteSqlValidator(
+			SqlOperatorTable opTab,
+			SqlValidatorCatalogReader catalogReader,
+			RelDataTypeFactory typeFactory) {
+		super(opTab, catalogReader, typeFactory, SqlConformanceEnum.DEFAULT);
+	}
+
+	@Override
+	protected RelDataType getLogicalSourceRowType(RelDataType sourceRowType, SqlInsert insert) {
+		return unwrapTypeFactory(typeFactory).toSql(sourceRowType);
+	}
+
+	@Override
+	protected RelDataType getLogicalTargetRowType(RelDataType targetRowType, SqlInsert insert) {
+		return unwrapTypeFactory(typeFactory).toSql(targetRowType);
+	}
 
 Review comment:
   Just out of curiosity. Do we need those methods?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services