[jira] [Commented] (CALCITE-6257) StarRocks dialect implementation
[ https://issues.apache.org/jira/browse/CALCITE-6257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17816395#comment-17816395 ] Caican Cai commented on CALCITE-6257: - As far as I know, the underlying sql protocol of starrocks is the same as doris. Do we need to support doris in the future or do we support it together in this pr > StarRocks dialect implementation > > > Key: CALCITE-6257 > URL: https://issues.apache.org/jira/browse/CALCITE-6257 > Project: Calcite > Issue Type: New Feature >Reporter: EveyWu >Priority: Minor > Labels: pull-request-available > > StarRocks has an MPP architecture and is equipped with a fully vectorized > execution engine, a columnar storage engine that supports real-time updates. > [https://docs.starrocks.io/docs/introduction/StarRocks_intro/] > At present, StarRocks has a wide range of applications. Implementing dialect > in Calcite will be valuable for many bi-services. > It closely follows MySQL but has enough differences to warrant a separate > dialect in Calcite. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Updated] (CALCITE-6259) Using log10 and log functions with arguments 0
[ https://issues.apache.org/jira/browse/CALCITE-6259?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Caican Cai updated CALCITE-6259: Attachment: 302662660-27b21670-5364-463c-b6dc-d750c46d7cd1-1.png > Using log10 and log functions with arguments 0 > -- > > Key: CALCITE-6259 > URL: https://issues.apache.org/jira/browse/CALCITE-6259 > Project: Calcite > Issue Type: Improvement > Components: core >Affects Versions: 1.36.0 >Reporter: Caican Cai >Priority: Major > Fix For: 1.37.0 > > Attachments: 302662660-27b21670-5364-463c-b6dc-d750c46d7cd1-1.png, > 302662660-27b21670-5364-463c-b6dc-d750c46d7cd1.png, > 302663876-91173a60-695d-409e-b325-3f91655c6d0d.png > > > When log10(0) returns null in mysql and spark, but log10 returns error in > postgres, neither is calcite's -Intity > {code:java} > postgres=# select log10(0); > ERROR: cannot take logarithm of zero > postgres=# select log(2,0); > ERROR: cannot take logarithm of zero > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (CALCITE-6259) Using log10 and log functions with arguments 0
Caican Cai created CALCITE-6259: --- Summary: Using log10 and log functions with arguments 0 Key: CALCITE-6259 URL: https://issues.apache.org/jira/browse/CALCITE-6259 Project: Calcite Issue Type: Improvement Components: core Affects Versions: 1.36.0 Reporter: Caican Cai Fix For: 1.37.0 Attachments: 302662660-27b21670-5364-463c-b6dc-d750c46d7cd1-1.png, 302662660-27b21670-5364-463c-b6dc-d750c46d7cd1.png, 302663876-91173a60-695d-409e-b325-3f91655c6d0d.png When log10(0) returns null in mysql and spark, but log10 returns error in postgres, neither is calcite's -Intity {code:java} postgres=# select log10(0); ERROR: cannot take logarithm of zero postgres=# select log(2,0); ERROR: cannot take logarithm of zero {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Updated] (CALCITE-6259) Using log10 and log functions with arguments 0
[ https://issues.apache.org/jira/browse/CALCITE-6259?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Caican Cai updated CALCITE-6259: Attachment: (was: 302662660-27b21670-5364-463c-b6dc-d750c46d7cd1-1.png) > Using log10 and log functions with arguments 0 > -- > > Key: CALCITE-6259 > URL: https://issues.apache.org/jira/browse/CALCITE-6259 > Project: Calcite > Issue Type: Improvement > Components: core >Affects Versions: 1.36.0 >Reporter: Caican Cai >Priority: Major > Fix For: 1.37.0 > > Attachments: 302662660-27b21670-5364-463c-b6dc-d750c46d7cd1.png, > 302663876-91173a60-695d-409e-b325-3f91655c6d0d.png > > > When log10(0) returns null in mysql and spark, but log10 returns error in > postgres, neither is calcite's -Intity > {code:java} > postgres=# select log10(0); > ERROR: cannot take logarithm of zero > postgres=# select log(2,0); > ERROR: cannot take logarithm of zero > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (CALCITE-6259) Using log10 and log functions with arguments 0
[ https://issues.apache.org/jira/browse/CALCITE-6259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17816413#comment-17816413 ] Caican Cai commented on CALCITE-6259: - Mysql and spark the results are shown in attachment or https://github.com/apache/calcite/pull/3648 > Using log10 and log functions with arguments 0 > -- > > Key: CALCITE-6259 > URL: https://issues.apache.org/jira/browse/CALCITE-6259 > Project: Calcite > Issue Type: Improvement > Components: core >Affects Versions: 1.36.0 >Reporter: Caican Cai >Priority: Major > Fix For: 1.37.0 > > Attachments: 302662660-27b21670-5364-463c-b6dc-d750c46d7cd1.png, > 302663876-91173a60-695d-409e-b325-3f91655c6d0d.png > > > When log10(0) returns null in mysql and spark, but log10 returns error in > postgres, neither is calcite's -Intity > {code:java} > postgres=# select log10(0); > ERROR: cannot take logarithm of zero > postgres=# select log(2,0); > ERROR: cannot take logarithm of zero > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (CALCITE-6259) Using log10 and log functions with arguments 0
[ https://issues.apache.org/jira/browse/CALCITE-6259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17816415#comment-17816415 ] Caican Cai commented on CALCITE-6259: - Do we need to modify log function in calcite. According to my observation, the log function of any sql dialect will follow this set of sqlfunctions logic {code:java} /** SQL {@code LOG(number, number2)} function applied to double values. */ public static double log(double d0, double d1) { return Math.log(d0) / Math.log(d1); } /** SQL {@code LOG(number, number2)} function applied to * double and BigDecimal values. */ public static double log(double d0, BigDecimal d1) { return Math.log(d0) / Math.log(d1.doubleValue()); } /** SQL {@code LOG(number, number2)} function applied to * BigDecimal and double values. */ public static double log(BigDecimal d0, double d1) { return Math.log(d0.doubleValue()) / Math.log(d1); } /** SQL {@code LOG(number, number2)} function applied to double values. */ public static double log(BigDecimal d0, BigDecimal d1) { return Math.log(d0.doubleValue()) / Math.log(d1.doubleValue()); } {code} > Using log10 and log functions with arguments 0 > -- > > Key: CALCITE-6259 > URL: https://issues.apache.org/jira/browse/CALCITE-6259 > Project: Calcite > Issue Type: Improvement > Components: core >Affects Versions: 1.36.0 >Reporter: Caican Cai >Priority: Major > Fix For: 1.37.0 > > Attachments: 302662660-27b21670-5364-463c-b6dc-d750c46d7cd1.png, > 302663876-91173a60-695d-409e-b325-3f91655c6d0d.png > > > When log10(0) returns null in mysql and spark, but log10 returns error in > postgres, neither is calcite's -Intity > {code:java} > postgres=# select log10(0); > ERROR: cannot take logarithm of zero > postgres=# select log(2,0); > ERROR: cannot take logarithm of zero > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Updated] (CALCITE-6259) Using log10 and log functions with arguments 0
[ https://issues.apache.org/jira/browse/CALCITE-6259?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Caican Cai updated CALCITE-6259: Description: When log10(0) returns null in mysql and spark, but log10(0) returns error in postgres, neither is calcite's -Intity {code:java} postgres=# select log10(0); ERROR: cannot take logarithm of zero postgres=# select log(2,0); ERROR: cannot take logarithm of zero {code} was: When log10(0) returns null in mysql and spark, but log10 returns error in postgres, neither is calcite's -Intity {code:java} postgres=# select log10(0); ERROR: cannot take logarithm of zero postgres=# select log(2,0); ERROR: cannot take logarithm of zero {code} > Using log10 and log functions with arguments 0 > -- > > Key: CALCITE-6259 > URL: https://issues.apache.org/jira/browse/CALCITE-6259 > Project: Calcite > Issue Type: Improvement > Components: core >Affects Versions: 1.36.0 >Reporter: Caican Cai >Priority: Major > Fix For: 1.37.0 > > Attachments: 302662660-27b21670-5364-463c-b6dc-d750c46d7cd1.png, > 302663876-91173a60-695d-409e-b325-3f91655c6d0d.png > > > When log10(0) returns null in mysql and spark, but log10(0) returns error in > postgres, neither is calcite's -Intity > {code:java} > postgres=# select log10(0); > ERROR: cannot take logarithm of zero > postgres=# select log(2,0); > ERROR: cannot take logarithm of zero > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Updated] (CALCITE-6259) Return the result with the log10 and log functions of argument 0
[ https://issues.apache.org/jira/browse/CALCITE-6259?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Caican Cai updated CALCITE-6259: Summary: Return the result with the log10 and log functions of argument 0 (was: Using log10 and log functions with arguments 0) > Return the result with the log10 and log functions of argument 0 > > > Key: CALCITE-6259 > URL: https://issues.apache.org/jira/browse/CALCITE-6259 > Project: Calcite > Issue Type: Improvement > Components: core >Affects Versions: 1.36.0 >Reporter: Caican Cai >Priority: Major > Fix For: 1.37.0 > > Attachments: 302662660-27b21670-5364-463c-b6dc-d750c46d7cd1.png, > 302663876-91173a60-695d-409e-b325-3f91655c6d0d.png > > > When log10(0) returns null in mysql and spark, but log10(0) returns error in > postgres, neither is calcite's -Intity > {code:java} > postgres=# select log10(0); > ERROR: cannot take logarithm of zero > postgres=# select log(2,0); > ERROR: cannot take logarithm of zero > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Comment Edited] (CALCITE-6259) Return the result with the log10 and log functions of argument 0
[ https://issues.apache.org/jira/browse/CALCITE-6259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17816415#comment-17816415 ] Caican Cai edited comment on CALCITE-6259 at 2/11/24 1:24 PM: -- Do we need to modify log function in calcite. According to my observation, the log function of any sql dialect will follow this set of sqlfunctions logic. So the log10(0) result for any sql dialect is -Intity {code:java} /** SQL {@code LOG(number, number2)} function applied to double values. */ public static double log(double d0, double d1) { return Math.log(d0) / Math.log(d1); } /** SQL {@code LOG(number, number2)} function applied to * double and BigDecimal values. */ public static double log(double d0, BigDecimal d1) { return Math.log(d0) / Math.log(d1.doubleValue()); } /** SQL {@code LOG(number, number2)} function applied to * BigDecimal and double values. */ public static double log(BigDecimal d0, double d1) { return Math.log(d0.doubleValue()) / Math.log(d1); } /** SQL {@code LOG(number, number2)} function applied to double values. */ public static double log(BigDecimal d0, BigDecimal d1) { return Math.log(d0.doubleValue()) / Math.log(d1.doubleValue()); } {code} was (Author: JIRAUSER302115): Do we need to modify log function in calcite. According to my observation, the log function of any sql dialect will follow this set of sqlfunctions logic {code:java} /** SQL {@code LOG(number, number2)} function applied to double values. */ public static double log(double d0, double d1) { return Math.log(d0) / Math.log(d1); } /** SQL {@code LOG(number, number2)} function applied to * double and BigDecimal values. */ public static double log(double d0, BigDecimal d1) { return Math.log(d0) / Math.log(d1.doubleValue()); } /** SQL {@code LOG(number, number2)} function applied to * BigDecimal and double values. */ public static double log(BigDecimal d0, double d1) { return Math.log(d0.doubleValue()) / Math.log(d1); } /** SQL {@code LOG(number, number2)} function applied to double values. */ public static double log(BigDecimal d0, BigDecimal d1) { return Math.log(d0.doubleValue()) / Math.log(d1.doubleValue()); } {code} > Return the result with the log10 and log functions of argument 0 > > > Key: CALCITE-6259 > URL: https://issues.apache.org/jira/browse/CALCITE-6259 > Project: Calcite > Issue Type: Improvement > Components: core >Affects Versions: 1.36.0 >Reporter: Caican Cai >Priority: Major > Fix For: 1.37.0 > > Attachments: 302662660-27b21670-5364-463c-b6dc-d750c46d7cd1.png, > 302663876-91173a60-695d-409e-b325-3f91655c6d0d.png > > > When log10(0) returns null in mysql and spark, but log10(0) returns error in > postgres, neither is calcite's -Intity > {code:java} > postgres=# select log10(0); > ERROR: cannot take logarithm of zero > postgres=# select log(2,0); > ERROR: cannot take logarithm of zero > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (CALCITE-6257) StarRocks dialect implementation
[ https://issues.apache.org/jira/browse/CALCITE-6257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17816467#comment-17816467 ] EveyWu commented on CALCITE-6257: -- hi [~caicancai] Similar to Presto and Trino, I don't think it's necessary to implement two sets of dialects at the moment. Since Starrocks is more widely used currently, I chose to implement the StarRocks Dialect. > StarRocks dialect implementation > > > Key: CALCITE-6257 > URL: https://issues.apache.org/jira/browse/CALCITE-6257 > Project: Calcite > Issue Type: New Feature >Reporter: EveyWu >Priority: Minor > Labels: pull-request-available > > StarRocks has an MPP architecture and is equipped with a fully vectorized > execution engine, a columnar storage engine that supports real-time updates. > [https://docs.starrocks.io/docs/introduction/StarRocks_intro/] > At present, StarRocks has a wide range of applications. Implementing dialect > in Calcite will be valuable for many bi-services. > It closely follows MySQL but has enough differences to warrant a separate > dialect in Calcite. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (CALCITE-6257) StarRocks dialect implementation
[ https://issues.apache.org/jira/browse/CALCITE-6257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17816470#comment-17816470 ] Caican Cai commented on CALCITE-6257: - hi [~eveywu] Thank you for your reply and I agree with you > StarRocks dialect implementation > > > Key: CALCITE-6257 > URL: https://issues.apache.org/jira/browse/CALCITE-6257 > Project: Calcite > Issue Type: New Feature >Reporter: EveyWu >Priority: Minor > Labels: pull-request-available > > StarRocks has an MPP architecture and is equipped with a fully vectorized > execution engine, a columnar storage engine that supports real-time updates. > [https://docs.starrocks.io/docs/introduction/StarRocks_intro/] > At present, StarRocks has a wide range of applications. Implementing dialect > in Calcite will be valuable for many bi-services. > It closely follows MySQL but has enough differences to warrant a separate > dialect in Calcite. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Comment Edited] (CALCITE-6259) Return the result with the log10 and log functions of argument 0
[ https://issues.apache.org/jira/browse/CALCITE-6259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17816489#comment-17816489 ] EveyWu edited comment on CALCITE-6259 at 2/12/24 5:24 AM: --- hi [~caicancai] I think we can optimize the log function calculation. According to the [[document|https://cloud.google.com/bigquery/docs/reference/standard-sql/mathematical_functions#log]|#log]], the current Caclite calculation for critical conditions does not conform to the behavior of bigquery. Such as: LOG(X [, Y]), LOG(0, Y) for bigquery is Error, but for Calcite is -Infinity; LOG10(0) for bigquery is Error, but for Calcite is -Infinity. I also think that the background of this issue should be confirmed with [~tanclary] was (Author: eveywu): hi [~caicancai] I think we can optimize the log function calculation. According to the [document|[https://cloud.google.com/bigquery/docs/reference/standard-sql/mathematical_functions#log]], the current Caclite calculation for critical conditions does not conform to the behavior of bigquery. Such as: LOG(X [, Y]), LOG(0, Y) for bigquery is Error, but for Calcite is -Infinity; LOG10(0) for bigquery is Error, but for Calcite is -Infinity. I also think that the background of this issue should be confirmed with [~tanclary] > Return the result with the log10 and log functions of argument 0 > > > Key: CALCITE-6259 > URL: https://issues.apache.org/jira/browse/CALCITE-6259 > Project: Calcite > Issue Type: Improvement > Components: core >Affects Versions: 1.36.0 >Reporter: Caican Cai >Priority: Major > Fix For: 1.37.0 > > Attachments: 302662660-27b21670-5364-463c-b6dc-d750c46d7cd1.png, > 302663876-91173a60-695d-409e-b325-3f91655c6d0d.png > > > When log10(0) returns null in mysql and spark, but log10(0) returns error in > postgres, neither is calcite's -Intity > {code:java} > postgres=# select log10(0); > ERROR: cannot take logarithm of zero > postgres=# select log(2,0); > ERROR: cannot take logarithm of zero > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (CALCITE-6259) Return the result with the log10 and log functions of argument 0
[ https://issues.apache.org/jira/browse/CALCITE-6259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17816489#comment-17816489 ] EveyWu commented on CALCITE-6259: -- hi [~caicancai] I think we can optimize the log function calculation. According to the [document|[https://cloud.google.com/bigquery/docs/reference/standard-sql/mathematical_functions#log]], the current Caclite calculation for critical conditions does not conform to the behavior of bigquery. Such as: LOG(X [, Y]), LOG(0, Y) for bigquery is Error, but for Calcite is -Infinity; LOG10(0) for bigquery is Error, but for Calcite is -Infinity. I also think that the background of this issue should be confirmed with [~tanclary] > Return the result with the log10 and log functions of argument 0 > > > Key: CALCITE-6259 > URL: https://issues.apache.org/jira/browse/CALCITE-6259 > Project: Calcite > Issue Type: Improvement > Components: core >Affects Versions: 1.36.0 >Reporter: Caican Cai >Priority: Major > Fix For: 1.37.0 > > Attachments: 302662660-27b21670-5364-463c-b6dc-d750c46d7cd1.png, > 302663876-91173a60-695d-409e-b325-3f91655c6d0d.png > > > When log10(0) returns null in mysql and spark, but log10(0) returns error in > postgres, neither is calcite's -Intity > {code:java} > postgres=# select log10(0); > ERROR: cannot take logarithm of zero > postgres=# select log(2,0); > ERROR: cannot take logarithm of zero > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Comment Edited] (CALCITE-6259) Return the result with the log10 and log functions of argument 0
[ https://issues.apache.org/jira/browse/CALCITE-6259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17816489#comment-17816489 ] EveyWu edited comment on CALCITE-6259 at 2/12/24 5:25 AM: --- hi [~caicancai] I think we can optimize the log function calculation. According to the [[document]|https://cloud.google.com/bigquery/docs/reference/standard-sql/mathematical_functions#log], the current Caclite calculation for critical conditions does not conform to the behavior of bigquery. Such as: LOG(X [, Y]), LOG(0, Y) for bigquery is Error, but for Calcite is -Infinity; LOG10(0) for bigquery is Error, but for Calcite is -Infinity. I also think that the background of this issue should be confirmed with [~tanclary] was (Author: eveywu): hi [~caicancai] I think we can optimize the log function calculation. According to the [[document|https://cloud.google.com/bigquery/docs/reference/standard-sql/mathematical_functions#log]|#log]], the current Caclite calculation for critical conditions does not conform to the behavior of bigquery. Such as: LOG(X [, Y]), LOG(0, Y) for bigquery is Error, but for Calcite is -Infinity; LOG10(0) for bigquery is Error, but for Calcite is -Infinity. I also think that the background of this issue should be confirmed with [~tanclary] > Return the result with the log10 and log functions of argument 0 > > > Key: CALCITE-6259 > URL: https://issues.apache.org/jira/browse/CALCITE-6259 > Project: Calcite > Issue Type: Improvement > Components: core >Affects Versions: 1.36.0 >Reporter: Caican Cai >Priority: Major > Fix For: 1.37.0 > > Attachments: 302662660-27b21670-5364-463c-b6dc-d750c46d7cd1.png, > 302663876-91173a60-695d-409e-b325-3f91655c6d0d.png > > > When log10(0) returns null in mysql and spark, but log10(0) returns error in > postgres, neither is calcite's -Intity > {code:java} > postgres=# select log10(0); > ERROR: cannot take logarithm of zero > postgres=# select log(2,0); > ERROR: cannot take logarithm of zero > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (CALCITE-6248) Illegal dates are accepted by casts
[ https://issues.apache.org/jira/browse/CALCITE-6248?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17816490#comment-17816490 ] Evgeny Stanilovsky commented on CALCITE-6248: - [~mbudiu] plz check discussion here [1] and check standard : "6.1 chapter, Valid values for datetime fields" so i think it is correct. [1] https://issues.apache.org/jira/browse/CALCITE-5957 > Illegal dates are accepted by casts > --- > > Key: CALCITE-6248 > URL: https://issues.apache.org/jira/browse/CALCITE-6248 > Project: Calcite > Issue Type: Bug > Components: avatica >Affects Versions: 1.36.0 >Reporter: Mihai Budiu >Priority: Minor > Labels: pull-request-available > Time Spent: 20m > Remaining Estimate: 0h > > The following test passes in SqlOperatorTest: > {code:java} > @Test public void testIllegalDate() { > final SqlOperatorFixture f = fixture(); > f.checkScalar("cast('1945-02-32' as DATE)", > "1945-03-04", "DATE NOT NULL"); > } > {code} > There is no February 32, I suspect that this expression should produce an > error. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Resolved] (CALCITE-6214) Remove DISTINCT in aggregate function if field is unique
[ https://issues.apache.org/jira/browse/CALCITE-6214?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Jiajun Xie resolved CALCITE-6214. - Fix Version/s: 1.37.0 Resolution: Fixed > Remove DISTINCT in aggregate function if field is unique > > > Key: CALCITE-6214 > URL: https://issues.apache.org/jira/browse/CALCITE-6214 > Project: Calcite > Issue Type: Improvement > Components: core >Reporter: Jiajun Xie >Assignee: Jiajun Xie >Priority: Minor > Labels: pull-request-available > Fix For: 1.37.0 > > > For the sql > {code:java} > select count(distinct x) cnt > from( >select distinct sal x from emp > ) t {code} > The distinct that in count can be removed. > {code:java} > LogicalAggregate(group=[{}], CNT=[COUNT($0)]) > LogicalAggregate(group=[{0}]) > LogicalProject(X=[$5]) > LogicalTableScan(table=[[CATALOG, SALES, EMP]]) {code} > But `CoreRules#AGGREGATE_REMOVE` not support it, so there are two DISTINCT. > {code:java} > LogicalAggregate(group=[{}], CNT=[COUNT(DISTINCT $0)]) > LogicalAggregate(group=[{0}]) > LogicalProject(X=[$5]) > LogicalTableScan(table=[[CATALOG, SALES, EMP]]) {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (CALCITE-6214) Remove DISTINCT in aggregate function if field is unique
[ https://issues.apache.org/jira/browse/CALCITE-6214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17816494#comment-17816494 ] Jiajun Xie commented on CALCITE-6214: - Fixed in [ec0dc3c|https://github.com/apache/calcite/commit/ec0dc3c886ef06020294dc80971c29ec3b90fa44] > Remove DISTINCT in aggregate function if field is unique > > > Key: CALCITE-6214 > URL: https://issues.apache.org/jira/browse/CALCITE-6214 > Project: Calcite > Issue Type: Improvement > Components: core >Reporter: Jiajun Xie >Assignee: Jiajun Xie >Priority: Minor > Labels: pull-request-available > > For the sql > {code:java} > select count(distinct x) cnt > from( >select distinct sal x from emp > ) t {code} > The distinct that in count can be removed. > {code:java} > LogicalAggregate(group=[{}], CNT=[COUNT($0)]) > LogicalAggregate(group=[{0}]) > LogicalProject(X=[$5]) > LogicalTableScan(table=[[CATALOG, SALES, EMP]]) {code} > But `CoreRules#AGGREGATE_REMOVE` not support it, so there are two DISTINCT. > {code:java} > LogicalAggregate(group=[{}], CNT=[COUNT(DISTINCT $0)]) > LogicalAggregate(group=[{0}]) > LogicalProject(X=[$5]) > LogicalTableScan(table=[[CATALOG, SALES, EMP]]) {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)