wuchong commented on a change in pull request #9994: [FLINK-14322][table-api]
Add watermark information in TableSchema
URL: https://github.com/apache/flink/pull/9994#discussion_r341509715
##########
File path:
flink-table/flink-table-common/src/main/java/org/apache/flink/table/api/TableSchema.java
##########
@@ -244,16 +272,46 @@ public boolean equals(Object o) {
}
TableSchema schema = (TableSchema) o;
return Arrays.equals(fieldNames, schema.fieldNames) &&
- Arrays.equals(fieldDataTypes, schema.fieldDataTypes);
+ Arrays.equals(fieldDataTypes, schema.fieldDataTypes) &&
+ watermarkSpecs.equals(schema.getWatermarkSpecs());
}
@Override
public int hashCode() {
int result = Arrays.hashCode(fieldNames);
result = 31 * result + Arrays.hashCode(fieldDataTypes);
+ result = 31 * result + watermarkSpecs.hashCode();
return result;
}
+ /**
+ * Creates a mapping from field name to data type, the field name can
be a nested field.
+ * This is mainly used for validating whether the rowtime attribute
(might be nested) exists
+ * in the schema. During creating, it also validates whether there is
duplicate field names.
+ *
+ * <p>For example, a "f0" field of ROW type has two nested fields "q1"
and "q2". Then the
+ * mapping will be ["f0" -> ROW, "f0.q1" -> INT, "f0.q2" -> STRING].
+ * <pre>
+ * {@code
+ * f0 ROW<q1 INT, q2 STRING>
+ * }
+ * </pre>
+ * @param fieldName name of this field, e.g. "q1" or "q2" in the above
example.
+ * @param fieldType data type of this field
+ * @param parentFieldName the field name of parent type, e.g. "f0" in
the above example.
+ */
+ private void validateAndCreateNameToTypeMapping(String fieldName,
DataType fieldType, String parentFieldName) {
+ String fullFieldName = parentFieldName.isEmpty() ? fieldName :
parentFieldName + "." + fieldName;
+ DataType oldType = fieldNameToType.put(fullFieldName,
fieldType);
Review comment:
We shouldn't pass `null`. If it can accept nullable String, then the
parameter should be annotated `@Nullable`, otherwise, it is not null.
Besides, it is only internally used and we guaranteed that.
----------------------------------------------------------------
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