You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "xiedeyantu (via GitHub)" <gi...@apache.org> on 2025/03/16 09:59:37 UTC

[PR] [CALCITE-6894] ClickHouse dialect can support another form of writing aggFilterWhere [calcite]

xiedeyantu opened a new pull request, #4247:
URL: https://github.com/apache/calcite/pull/4247

   Jira link: [CALCITE-6894](https://issues.apache.org/jira/browse/CALCITE-6894)


-- 
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


Re: [PR] [CALCITE-6894] ClickHouse dialect can support another form of writing aggFilterWhere [calcite]

Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #4247:
URL: https://github.com/apache/calcite/pull/4247#discussion_r2014063084


##########
core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java:
##########
@@ -181,6 +188,21 @@ private static SqlDataTypeSpec createSqlDataTypeSpecByName(String typeAlias,
       return;
     }
 
+    if (call.getOperator() instanceof SqlFilterOperator) {
+      SqlCall aggCall = call.operand(0);
+      if (call.getOperandList().size() > 1 && call.operand(1) != null) {
+        SqlCall filterCondition = call.operand(1);
+        String functionName = aggCall.getOperator().getName();
+        writer.print(functionName.toLowerCase(Locale.ROOT) + "If");

Review Comment:
   @xiedeyantu No, according to your writing above, all aggregate functions will execute the logic of your method. If some functions of ClickHouse are not supported by Calcite, you at least need to record JavaDoc for explanation.
   
   



-- 
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


Re: [PR] [CALCITE-6894] ClickHouse dialect can support another form of writing aggFilterWhere [calcite]

Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #4247:
URL: https://github.com/apache/calcite/pull/4247#discussion_r2014063084


##########
core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java:
##########
@@ -181,6 +188,21 @@ private static SqlDataTypeSpec createSqlDataTypeSpecByName(String typeAlias,
       return;
     }
 
+    if (call.getOperator() instanceof SqlFilterOperator) {
+      SqlCall aggCall = call.operand(0);
+      if (call.getOperandList().size() > 1 && call.operand(1) != null) {
+        SqlCall filterCondition = call.operand(1);
+        String functionName = aggCall.getOperator().getName();
+        writer.print(functionName.toLowerCase(Locale.ROOT) + "If");

Review Comment:
   @xiedeyantu No, according to your writing above, all aggregate functions will execute the logic of your method, but you only described the sum aggregate function in the jira case, which seems a bit strange. If some functions of ClickHouse are not supported by Calcite, you at least need to record JavaDoc to explain it.
   



-- 
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


Re: [PR] [CALCITE-6894] ClickHouse dialect can support another form of writing aggFilterWhere [calcite]

Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on code in PR #4247:
URL: https://github.com/apache/calcite/pull/4247#discussion_r2013048511


##########
core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java:
##########
@@ -181,6 +188,21 @@ private static SqlDataTypeSpec createSqlDataTypeSpecByName(String typeAlias,
       return;
     }
 
+    if (call.getOperator() instanceof SqlFilterOperator) {
+      SqlCall aggCall = call.operand(0);
+      if (call.getOperandList().size() > 1 && call.operand(1) != null) {
+        SqlCall filterCondition = call.operand(1);
+        String functionName = aggCall.getOperator().getName();
+        writer.print(functionName.toLowerCase(Locale.ROOT) + "If");

Review Comment:
   Thanks for review it. Clickhouse has such a logic. It will concatenate the aggregate function and -If instead of implementing a new xxxIf function. For example, whether stddevIf exists depends on whether Clickhouse supports stddev. I understand that the conversion of pr is correct. If more precision is needed, we may need to do a good job of mapping the functions from calcite to Clickhouse, but it seems that each dialect is being implemented one by one, which may be an area that needs improvement.



-- 
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


Re: [PR] [CALCITE-6894] ClickHouse dialect can support another form of writing aggFilterWhere [calcite]

Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #4247:
URL: https://github.com/apache/calcite/pull/4247#discussion_r2014057193


##########
core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java:
##########
@@ -181,6 +188,21 @@ private static SqlDataTypeSpec createSqlDataTypeSpecByName(String typeAlias,
       return;
     }
 
+    if (call.getOperator() instanceof SqlFilterOperator) {
+      SqlCall aggCall = call.operand(0);
+      if (call.getOperandList().size() > 1 && call.operand(1) != null) {
+        SqlCall filterCondition = call.operand(1);
+        String functionName = aggCall.getOperator().getName();
+        writer.print(functionName.toLowerCase(Locale.ROOT) + "If");

Review Comment:
   @mihaibudiu In my impression, ClickHouse does not seem to support stddevif



-- 
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


Re: [PR] [CALCITE-6894] ClickHouse dialect can support another form of writing aggFilterWhere [calcite]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4247:
URL: https://github.com/apache/calcite/pull/4247#issuecomment-2727317337

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4247) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4247&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4247&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4247&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [89.5% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4247&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4247&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4247)
   
   


-- 
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


Re: [PR] [CALCITE-6894] ClickHouse dialect can support another form of writing aggFilterWhere [calcite]

Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on code in PR #4247:
URL: https://github.com/apache/calcite/pull/4247#discussion_r2013160863


##########
core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java:
##########
@@ -181,6 +188,21 @@ private static SqlDataTypeSpec createSqlDataTypeSpecByName(String typeAlias,
       return;
     }
 
+    if (call.getOperator() instanceof SqlFilterOperator) {
+      SqlCall aggCall = call.operand(0);
+      if (call.getOperandList().size() > 1 && call.operand(1) != null) {
+        SqlCall filterCondition = call.operand(1);
+        String functionName = aggCall.getOperator().getName();
+        writer.print(functionName.toLowerCase(Locale.ROOT) + "If");

Review Comment:
   I think what you're saying is another issue, even if CASE WHEN is still used, if ClickHouse doesn't support STDDEV, then it can't also work. What do you think about creating another topic if needed?



-- 
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


Re: [PR] [CALCITE-6894] ClickHouse dialect can support another form of writing aggFilterWhere [calcite]

Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on code in PR #4247:
URL: https://github.com/apache/calcite/pull/4247#discussion_r2014225423


##########
core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java:
##########
@@ -181,6 +188,21 @@ private static SqlDataTypeSpec createSqlDataTypeSpecByName(String typeAlias,
       return;
     }
 
+    if (call.getOperator() instanceof SqlFilterOperator) {
+      SqlCall aggCall = call.operand(0);
+      if (call.getOperandList().size() > 1 && call.operand(1) != null) {
+        SqlCall filterCondition = call.operand(1);
+        String functionName = aggCall.getOperator().getName();
+        writer.print(functionName.toLowerCase(Locale.ROOT) + "If");

Review Comment:
   > Whether clickhouse supports stddev is what I am asking. Calcite supports a set of aggregates, and clickhouse supports another set. If the Calcite set is included in the Clickhouse set, this change is fine.
   
   @mihaibudiu After seeing your and cancai's replies, maybe I didn't explain clearly enough. Let me elaborate on the issue I mentioned:
   ClickHouse doesn't support stddev. Converting stddev(x) filter(where) to stddevIf(x, condition) will throw an error in ClickHouse. What I meant in my previous reply was that using stddev(case when) would also throw an error. This PR is just making a formal transformation.
   If we want to properly solve whether aggregate functions or other functions can be correctly translated, maybe creating a new JIRA ticket would be better. What do you think?



-- 
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


Re: [PR] [CALCITE-6894] ClickHouse dialect can support another form of writing aggFilterWhere [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4247:
URL: https://github.com/apache/calcite/pull/4247#discussion_r2013142340


##########
core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java:
##########
@@ -181,6 +188,21 @@ private static SqlDataTypeSpec createSqlDataTypeSpecByName(String typeAlias,
       return;
     }
 
+    if (call.getOperator() instanceof SqlFilterOperator) {
+      SqlCall aggCall = call.operand(0);
+      if (call.getOperandList().size() > 1 && call.operand(1) != null) {
+        SqlCall filterCondition = call.operand(1);
+        String functionName = aggCall.getOperator().getName();
+        writer.print(functionName.toLowerCase(Locale.ROOT) + "If");

Review Comment:
   Whether clickhouse supports stddev is what I am asking.
   Calcite supports a set of aggregates, and clickhouse supports another set. If the Calcite set is included in the Clickhouse set, this change is fine.



-- 
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


Re: [PR] [CALCITE-6894] ClickHouse dialect can support another form of writing aggFilterWhere [calcite]

Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #4247:
URL: https://github.com/apache/calcite/pull/4247#discussion_r2014068819


##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -361,7 +361,13 @@ private static String toSql(RelNode root, SqlDialect dialect,
         + "FROM `foodmart`.`product`\n"
         + "WHERE `product_id` > 0\n"
         + "GROUP BY `product_id`";
+    final String expectedClickHouse = "SELECT"

Review Comment:
   Can you add more tests for different types of aggregate functions?



-- 
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


Re: [PR] [CALCITE-6894] ClickHouse dialect can support another form of writing aggFilterWhere [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4247:
URL: https://github.com/apache/calcite/pull/4247#discussion_r2014943831


##########
core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java:
##########
@@ -181,6 +188,21 @@ private static SqlDataTypeSpec createSqlDataTypeSpecByName(String typeAlias,
       return;
     }
 
+    if (call.getOperator() instanceof SqlFilterOperator) {
+      SqlCall aggCall = call.operand(0);
+      if (call.getOperandList().size() > 1 && call.operand(1) != null) {
+        SqlCall filterCondition = call.operand(1);
+        String functionName = aggCall.getOperator().getName();
+        writer.print(functionName.toLowerCase(Locale.ROOT) + "If");

Review Comment:
   Clickhouse supports stddev_samp and stddev_pop.
   Converting unsupported code to unsupported code is not really helpful.
   I think this code should handle correctly the supported functions and should report an error for the other cases



-- 
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


Re: [PR] [CALCITE-6894] ClickHouse dialect can support another form of writing aggFilterWhere [calcite]

Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on code in PR #4247:
URL: https://github.com/apache/calcite/pull/4247#discussion_r2016189777


##########
core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java:
##########
@@ -181,6 +188,21 @@ private static SqlDataTypeSpec createSqlDataTypeSpecByName(String typeAlias,
       return;
     }
 
+    if (call.getOperator() instanceof SqlFilterOperator) {
+      SqlCall aggCall = call.operand(0);
+      if (call.getOperandList().size() > 1 && call.operand(1) != null) {
+        SqlCall filterCondition = call.operand(1);
+        String functionName = aggCall.getOperator().getName();
+        writer.print(functionName.toLowerCase(Locale.ROOT) + "If");

Review Comment:
   Well, I understand. We may not need this PR. Correctly supporting function conversion may be a problem faced by all dialects. If this PR only handles some aggregation functions supported by ClickHouse, it may not be a good solution. So I will temporarily close this PR for now.



-- 
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


Re: [PR] [CALCITE-6894] ClickHouse dialect can support another form of writing aggFilterWhere [calcite]

Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on code in PR #4247:
URL: https://github.com/apache/calcite/pull/4247#discussion_r2014078971


##########
core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java:
##########
@@ -181,6 +188,21 @@ private static SqlDataTypeSpec createSqlDataTypeSpecByName(String typeAlias,
       return;
     }
 
+    if (call.getOperator() instanceof SqlFilterOperator) {
+      SqlCall aggCall = call.operand(0);
+      if (call.getOperandList().size() > 1 && call.operand(1) != null) {
+        SqlCall filterCondition = call.operand(1);
+        String functionName = aggCall.getOperator().getName();
+        writer.print(functionName.toLowerCase(Locale.ROOT) + "If");

Review Comment:
   Thanks, do I just need to add some extra comments? I want to confirm whether this conversion is needed. In fact, this conversion cannot solve the function mapping between the two dialects. This is actually similar to the syntax sugar of ClickHouse dialect.



-- 
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


Re: [PR] [CALCITE-6894] ClickHouse dialect can support another form of writing aggFilterWhere [calcite]

Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #4247:
URL: https://github.com/apache/calcite/pull/4247#discussion_r2014063084


##########
core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java:
##########
@@ -181,6 +188,21 @@ private static SqlDataTypeSpec createSqlDataTypeSpecByName(String typeAlias,
       return;
     }
 
+    if (call.getOperator() instanceof SqlFilterOperator) {
+      SqlCall aggCall = call.operand(0);
+      if (call.getOperandList().size() > 1 && call.operand(1) != null) {
+        SqlCall filterCondition = call.operand(1);
+        String functionName = aggCall.getOperator().getName();
+        writer.print(functionName.toLowerCase(Locale.ROOT) + "If");

Review Comment:
   No, according to your writing above, all aggregate functions will execute the logic of your method. If some functions of ClickHouse are not supported by Calcite, you at least need to record JavaDoc for explanation.



-- 
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


Re: [PR] [CALCITE-6894] ClickHouse dialect can support another form of writing aggFilterWhere [calcite]

Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #4247:
URL: https://github.com/apache/calcite/pull/4247#discussion_r2014063084


##########
core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java:
##########
@@ -181,6 +188,21 @@ private static SqlDataTypeSpec createSqlDataTypeSpecByName(String typeAlias,
       return;
     }
 
+    if (call.getOperator() instanceof SqlFilterOperator) {
+      SqlCall aggCall = call.operand(0);
+      if (call.getOperandList().size() > 1 && call.operand(1) != null) {
+        SqlCall filterCondition = call.operand(1);
+        String functionName = aggCall.getOperator().getName();
+        writer.print(functionName.toLowerCase(Locale.ROOT) + "If");

Review Comment:
   @xiedeyantu No, according to your writing above, all aggregate functions will be executed in your method. If some functions of ClickHouse are not supported by Calcite, you at least need to record JavaDoc to explain it.



-- 
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


Re: [PR] [CALCITE-6894] ClickHouse dialect can support another form of writing aggFilterWhere [calcite]

Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4247:
URL: https://github.com/apache/calcite/pull/4247#discussion_r2012508615


##########
core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java:
##########
@@ -181,6 +188,21 @@ private static SqlDataTypeSpec createSqlDataTypeSpecByName(String typeAlias,
       return;
     }
 
+    if (call.getOperator() instanceof SqlFilterOperator) {
+      SqlCall aggCall = call.operand(0);
+      if (call.getOperandList().size() > 1 && call.operand(1) != null) {
+        SqlCall filterCondition = call.operand(1);
+        String functionName = aggCall.getOperator().getName();
+        writer.print(functionName.toLowerCase(Locale.ROOT) + "If");

Review Comment:
   does this work for all aggregate functions?
   Is there a stddevif?



-- 
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


Re: [PR] [CALCITE-6894] ClickHouse dialect can support another form of writing aggFilterWhere [calcite]

Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on code in PR #4247:
URL: https://github.com/apache/calcite/pull/4247#discussion_r2016208119


##########
core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java:
##########
@@ -181,6 +188,21 @@ private static SqlDataTypeSpec createSqlDataTypeSpecByName(String typeAlias,
       return;
     }
 
+    if (call.getOperator() instanceof SqlFilterOperator) {
+      SqlCall aggCall = call.operand(0);
+      if (call.getOperandList().size() > 1 && call.operand(1) != null) {
+        SqlCall filterCondition = call.operand(1);
+        String functionName = aggCall.getOperator().getName();
+        writer.print(functionName.toLowerCase(Locale.ROOT) + "If");

Review Comment:
   But the - If form does have performance improvements, it's not just a formal transformation. see https://github.com/ClickHouse/ClickHouse/pull/17043 and others.



-- 
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


Re: [PR] [CALCITE-6894] ClickHouse dialect can support another form of writing aggFilterWhere [calcite]

Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu closed pull request #4247: [CALCITE-6894] ClickHouse dialect can support another form of writing aggFilterWhere
URL: https://github.com/apache/calcite/pull/4247


-- 
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


Re: [PR] [CALCITE-6894] ClickHouse dialect can support another form of writing aggFilterWhere [calcite]

Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #4247:
URL: https://github.com/apache/calcite/pull/4247#discussion_r2014057193


##########
core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java:
##########
@@ -181,6 +188,21 @@ private static SqlDataTypeSpec createSqlDataTypeSpecByName(String typeAlias,
       return;
     }
 
+    if (call.getOperator() instanceof SqlFilterOperator) {
+      SqlCall aggCall = call.operand(0);
+      if (call.getOperandList().size() > 1 && call.operand(1) != null) {
+        SqlCall filterCondition = call.operand(1);
+        String functionName = aggCall.getOperator().getName();
+        writer.print(functionName.toLowerCase(Locale.ROOT) + "If");

Review Comment:
   @mihaibudiu In my impression, ClickHouse does not seem to support stddevif



-- 
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