dawidwys commented on a change in pull request #10213:
[FLINK-12846][table-common] Carry primary key information in TableSchema
URL: https://github.com/apache/flink/pull/10213#discussion_r346833836
##########
File path:
flink-table/flink-table-common/src/test/java/org/apache/flink/table/api/TableSchemaTest.java
##########
@@ -192,4 +198,52 @@ public void testDifferentWatermarkStrategyOutputTypes() {
});
}
+ @Test
+ public void testInvalidPrimaryKeyFieldName() {
+ thrown.expectMessage("The primary key field 'd' is not existed
in the schema");
+ TableSchema.builder()
+ .field("a", DataTypes.INT())
+ .field("b", DataTypes.STRING())
+ .field("c", DataTypes.BIGINT())
+ .primaryKey("a", "d")
+ .build();
+ }
+
+ @Test
+ public void testInvalidPrimaryKeyNestedFieldName() {
+ thrown.expectMessage(
+ "The primary key field 'c.q1' is not existed in the
schema");
+ TableSchema.builder()
+ .field("a", DataTypes.INT())
+ .field("b", DataTypes.STRING())
+ .field("c", DataTypes.ROW(
+ DataTypes.FIELD("q1", DataTypes.STRING()),
+ DataTypes.FIELD("q2", DataTypes.TIMESTAMP(3))))
+ .primaryKey("b", "c.q1")
+ .build();
+ }
+
+ @Test
+ public void testInvalidMultiPrimaryKey() {
+ thrown.expectMessage(
+ "A primary key [a] have been defined, can not define
another primary key [b]");
Review comment:
```suggestion
"A primary key [a] has already been defined. Can not
define another primary key [b]");
```
----------------------------------------------------------------
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