xuzifu666 commented on code in PR #5275:
URL: https://github.com/apache/calcite/pull/5275#discussion_r4051831082
##########
core/src/main/java/org/apache/calcite/sql/validate/SetopNamespace.java:
##########
@@ -112,6 +116,25 @@ private static SqlMonotonicity combine(@Nullable
SqlMonotonicity m0,
}
validator.validateQuery(operand, scope, targetRowType);
}
+ // Propagate the operands' filter requirements to this namespace.
+ ImmutableBitSet filterFields = ImmutableBitSet.of();
+ @Nullable ImmutableBitSet bypassFields = null;
+ final Set<SqlQualified> remnantFilterFields = new LinkedHashSet<>();
+ for (SqlNode operand : call.getOperandList()) {
+ final SqlValidatorNamespace operandNamespace =
+ requireNonNull(validator.getNamespace(operand),
+ () -> "namespace for " + operand);
+ final FilterRequirement requirement =
operandNamespace.getFilterRequirement();
Review Comment:
Here, one might need to consider that cross-bypass fields spanning set
operation operands could result in valid queries being rejected.
##########
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java:
##########
@@ -4719,12 +4748,11 @@ private static void purgeForBypassFields(SqlNode node,
SqlValidatorScope scope,
.collect(Collectors.toList());
sameIdentifier.forEach(qualifieds::remove);
- // Clear all the remnant must-filter qualifieds from the same table
identifier
- Collection<SqlQualified> sameIdentifier_ =
- remnantMustFilterFields.stream()
- .filter(q -> qualifiedMatchesIdentifier(q, qualified))
- .collect(Collectors.toList());
- sameIdentifier_.forEach(remnantMustFilterFields::remove);
+ // Clear the remnant must-filter qualifieds imported through the
+ // same FROM item (namespace) as the filtered bypass field
+ if (qualified.namespace != null) {
Review Comment:
Could it be that, within the same subquery, a bypass for one table
incorrectly clears the remnant of another?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]