You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "libenchao (via GitHub)" <gi...@apache.org> on 2023/05/10 05:00:27 UTC
[GitHub] [calcite] libenchao commented on a diff in pull request #3191: [CALCITE-5693] AssertionError with UNION using CTE
libenchao commented on code in PR #3191:
URL: https://github.com/apache/calcite/pull/3191#discussion_r1189356925
##########
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java:
##########
@@ -4021,19 +4021,30 @@ private void validateModality(SqlNode query) {
default:
break;
}
+ } else if (query.getKind() == SqlKind.WITH) {
+ SqlWith with = (SqlWith) query;
+ for (SqlNode item : with.withList) {
+ SqlNode operand = ((SqlWithItem) item).query;
+ validateModality(operand, modality);
+ }
+ validateModality(with.body, modality);
} else {
assert query.isA(SqlKind.SET_QUERY);
final SqlCall call = (SqlCall) query;
for (SqlNode operand : call.getOperandList()) {
- if (deduceModality(operand) != modality) {
- throw newValidationError(operand,
- Static.RESOURCE.streamSetOpInconsistentInputs());
- }
- validateModality(operand);
+ validateModality(operand, modality);
}
}
}
+ private void validateModality(SqlNode operand, SqlModality modality) {
+ if (deduceModality(operand) != modality) {
+ throw newValidationError(operand,
+ Static.RESOURCE.streamSetOpInconsistentInputs());
Review Comment:
The exception is no longer accurate since you are also validating with list.
##########
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java:
##########
@@ -4021,19 +4021,30 @@ private void validateModality(SqlNode query) {
default:
break;
}
+ } else if (query.getKind() == SqlKind.WITH) {
Review Comment:
This would open the door to support `WITH` in streaming, then it would be great to have some tests for this.
##########
core/src/test/java/org/apache/calcite/test/JdbcAdapterTest.java:
##########
@@ -135,6 +135,14 @@ class JdbcAdapterTest {
+ "WHERE \"product_id\" = 1");
}
+ @Test void testFilterUnionIncludingWithPlan() {
Review Comment:
Since the exception is thrown in the validating phase, it's better to add the test to `SqlValidatorTest`
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org