twalthr commented on a change in pull request #9275:
[FLINK-13290][table-planner-blink][hbase] SinkCodeGenerator should not compare
row type field names and enable blink planner for hbase IT case
URL: https://github.com/apache/flink/pull/9275#discussion_r309222303
##########
File path:
flink-table/flink-table-common/src/main/java/org/apache/flink/table/types/logical/utils/LogicalTypeChecks.java
##########
@@ -332,4 +351,162 @@ public Boolean visit(DayTimeIntervalType
dayTimeIntervalType) {
}
}
}
+
+ private static class TypeEquivalenceIgnoreNamesExtractor extends
Extractor<Boolean> {
+
+ private final LogicalType thisType;
+
+ private TypeEquivalenceIgnoreNamesExtractor(LogicalType
thisType) {
+ this.thisType = thisType;
+ }
+
+ /**
+ * Returns true if tow LogicalType can equal. This is the same
with {@link LogicalType#equals(Object)}.
+ */
+ private boolean canEqual(LogicalType thatType) {
+ if (thisType == null || thatType == null) {
+ return false;
+ }
+ if (thisType == thatType) {
+ return true;
+ }
+ if (thisType.getClass() != thatType.getClass()) {
+ return false;
+ }
+ return thisType.isNullable() == thatType.isNullable()
+ && thisType.getTypeRoot() ==
thatType.getTypeRoot();
+ }
+
+ @Override
+ protected Boolean defaultMethod(LogicalType thatType) {
+ if (canEqual(thatType)) {
+ // for atomic types, we use equals simply.
+ return thisType.equals(thatType);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public Boolean visit(RowType thatType) {
+ if (!canEqual(thatType)) {
+ return false;
+ }
+ List<RowType.RowField> thisFields = ((RowType)
thisType).getFields();
+ List<RowType.RowField> thatFields =
thatType.getFields();
+ if (thisFields.size() != thatFields.size()) {
+ return false;
+ }
+ for (int i = 0; i < thisFields.size(); i++) {
+ RowType.RowField thisField = thisFields.get(i);
+ RowType.RowField thatField = thatFields.get(i);
+ // ignore field names
+ if
(!thisField.getType().equals(thatField.getType())
+ ||
!Objects.equals(thisField.getDescription(), thatField.getDescription())) {
Review comment:
We do we check the description? Isn't it as meaningless as the field 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