dawidwys commented on a change in pull request #10340: [FLINK-14978][table-api] 
Introduce constraint class hierarchy required for primary keys
URL: https://github.com/apache/flink/pull/10340#discussion_r353099032
 
 

 ##########
 File path: 
flink-table/flink-table-common/src/main/java/org/apache/flink/table/api/constraints/KeyConstraint.java
 ##########
 @@ -0,0 +1,100 @@
+/*
+ * 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.api.constraints;
+
+import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.table.api.ValidationException;
+import org.apache.flink.table.expressions.FieldReferenceExpression;
+
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import static org.apache.flink.util.Preconditions.checkNotNull;
+
+/**
+ * A unique key constraint. It can be declared also as a PRIMARY KEY.
+ *
+ * @see ConstraintType
+ */
+@PublicEvolving
+public final class KeyConstraint extends AbstractConstraint {
+       private final List<FieldReferenceExpression> columns;
 
 Review comment:
   I had a longer investigation on here. In a longer run I think we should 
adjust the `QueryOperation` and `Table` a bit so they do not return a full 
blown `TableSchema`. They should never care about the unique constraints, 
watermarks etc.
   
   I checked what information other databases store and they do store 
information that might need to be resolved (e.g. for primary keys column name 
and position within the declaration of constraint, for computed columns the 
expression). Therefore if we assume the TableSchema needs to be resolved I do 
agree with you we should store only the column names.

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


With regards,
Apache Git Services

Reply via email to