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 2019/12/02 08:44:27 UTC

[GitHub] [flink] dawidwys commented on a change in pull request #10340: [FLINK-14978][table-api] Introduce constraint class hierarchy required for primary keys

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_r352471857
 
 

 ##########
 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:
   Personally I would prefer to have the `FieldReferenceExpression` here. Exactly for the `inputIndex` and `fieldIndex info, as it might be helpful for a queries that have two inputs (it might not). In general I think schema should be fixed after every modification. In general `fieldIndex` should always be source of truth for any field references.
   
   Is it that hard though? The `KeyConstraint` class is sort of a second level API. Users should rather not use it. They should go against the `TableSchema` which exposes method `primaryKey(String name, String[] columns)`, which performs the resolution.
   
   This resolution has to be performed anyway at some point.

----------------------------------------------------------------
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