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/02/19 01:24:31 UTC
[GitHub] [calcite] libenchao commented on a diff in pull request #3055: [CALCITE-5507] HAVING alias failed when aggregate function in condition
libenchao commented on code in PR #3055:
URL: https://github.com/apache/calcite/pull/3055#discussion_r1111133185
##########
core/src/test/java/org/apache/calcite/test/SqlToRelConverterTest.java:
##########
@@ -385,6 +385,23 @@ public static void checkActualAndReferenceFiles() {
.withConformance(SqlConformanceEnum.LENIENT).ok();
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-5507">[CALCITE-5507]
+ * HAVING alias failed when aggregate function in condition</a>. */
+ @Test void testAggregateFunAndAliasInHaving1() {
+ sql("select count(empno) as e\n"
+ + "from emp\n"
+ + "having e > 10 and count(empno) > 10")
+ .withConformance(SqlConformanceEnum.LENIENT).ok();
+ }
+
+ @Test void testAggregateFunAndAliasInHaving2() {
+ sql("select count(empno) as e\n"
+ + "from emp\n"
+ + "having e > 10 or count(empno) < 5")
Review Comment:
I'm not sure if we need to have a different test which has only a minor difference with `testAggregateFunAndAliasInHaving1` (from `AND` to `OR`)
##########
core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java:
##########
@@ -6888,6 +6891,31 @@ static class ExtendedExpander extends Expander {
return super.visit(literal);
}
+
+ /**
+ * Returns whether a given node contains a {@link SqlIdentifier}.
+ *
+ * @param parent a SqlNode
+ * @param children a SqlIdentifier
+ */
+ private boolean containsIdentifier(SqlNode parent, SqlIdentifier children) {
Review Comment:
There is no need to use plural for second parameter. Further more, we even do not need to name them 'parent, child', it's not helpful for readability in my opinion.
How about name it `containsIdentifier(SqlNode sqlNode, SqlIdentifier target)`?
--
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