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/10/12 15:49:58 UTC
[PR] [CALCITE-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
xiedeyantu opened a new pull request, #4577:
URL: https://github.com/apache/calcite/pull/4577
See: [CALCITE-7122](https://issues.apache.org/jira/browse/CALCITE-7122)
I've implemented a rough draft for this JIRA ticket based on my understanding. The actual implementation for idempotent elimination is referenced from the original author. The logic I refactored is as follows:
1. Allow functions to provide their own idempotent property, instead of maintaining a list of which functions are idempotent (this addresses a point I've been emphasizing).
2. Handle idempotent functions in an appropriate location, avoiding scattering the idempotent elimination logic across too many places (another point I previously mentioned).
3. Since the current JIRA describes eliminating unary idempotent functions, I suggest temporarily excluding `FLOOR` and `CEIL` from consideration.
I haven't modified the test cases from the original PR #4488 , as I want to use them to verify the functional equivalence of the current code. If this implementation approach is approved, we can establish more specific requirements for test cases in the future.
This is just an idea for your reference.
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3402386803
I have changed my mind, I don't think this is an ideal design for two reasons:
- it is not sustainable to add flags to all functions for every property that may be interesting
- simplify is not the right place for all optimizations; this optimization in particular should be done only once, while simplify runs frequently.
I think the right way to solve this is through a visitor pattern; the visitor will know which functions are idempotent.
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3399633989
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4577) **Quality Gate passed**
Issues
 [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4577&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4577&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4577&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [97.8% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4577&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4577&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4577)
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3399381336
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4577) **Quality Gate passed**
Issues
 [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4577&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4577&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4577&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [97.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4577&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4577&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4577)
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3431508273
This proposed solution was not accepted, so I am closing this issue 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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3395010180
Could be a valid approach. It's aligned with already existing aspects like "deterministic" and "dynamic".
Maybe in the long run we could even consider combining these fields (`deterministic`, `dynamic`, `idempotent`, and any other that may come) into a single flag field instead of N booleans.
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3406106895
I have rolled back the code to the boolean-based implementation. If it gains approval, it can be merged. If it doesn’t receive consensus, I will still keep the PR open here, as it aligns with my design.
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3406142991
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4577) **Quality Gate passed**
Issues
 [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4577&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4577&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4577&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [97.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4577&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4577&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4577)
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3397467039
> Could be a valid approach. It's aligned with already existing aspects like "deterministic" and "dynamic". Maybe in the long run we could even consider combining these fields (`deterministic`, `dynamic`, `idempotent`, and any other that may come) into a single flag field instead of N booleans.
I have filed a jira [CALCITE-7224](https://issues.apache.org/jira/browse/CALCITE-7224) to record 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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3399370822
Yes, I think that once you make them Boolean, you can't change them to something else.
Let's see if anyone else has a different suggestion.
People may not like a lot of tiny enum classes, but from my experience they are not too bad, and they provide very strong typing.
In general, if you can wrap an abstraction, no matter how small, in a class, I think it's worth wrapping (unless performance is a concern).
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3399366577
> Yes, I saw that, but that may require changing signatures for these functions...
I'd like to confirm whether you're suggesting that using an enum containing two attributes, IDEMPOTENT and NONIDEMPOTENT, is a better approach in the current implementation, without having to worry about the original implementation style for now? Are you considering refactoring in the future?
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3402446103
> I have changed my mind, I don't think this is an ideal design for two reasons:
>
> * it is not sustainable to add flags to all functions for every property that may be interesting
> * simplify is not the right place for all optimizations; this optimization in particular should be done only once, while simplify runs frequently.
> I think the right way to solve this is through a visitor pattern; the visitor will know which functions are idempotent.
I don't entirely agree with your perspective. On the contrary, I believe adding possible function properties to `SqlOperator` is very appropriate. Moreover, if the refactoring is done well, adding future properties will be straightforward. Although `simplify` may be called frequently, the actual processing might only occur once. However, this optimization point is indeed very niche. If it's deemed unnecessary to implement, I think we could also close this JIRA.
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on code in PR #4577:
URL: https://github.com/apache/calcite/pull/4577#discussion_r2429335455
##########
core/src/main/java/org/apache/calcite/sql/SqlBasicFunction.java:
##########
@@ -180,35 +195,40 @@ public static SqlBasicFunction create(String name,
return dynamic;
}
+ @Override public boolean isIdempotent() {
+ return idempotent;
+ }
+
/** Returns a copy of this function with a given name. */
public SqlBasicFunction withName(String name) {
return new SqlBasicFunction(name, kind, syntax, deterministic,
getReturnTypeInference(), getOperandTypeInference(), operandHandler,
getOperandTypeChecker(), callValidator,
- getFunctionType(), monotonicityInference, dynamic);
+ getFunctionType(), monotonicityInference, dynamic, idempotent);
Review Comment:
@rubenada Indeed, using a boolean type aligns with the current design, which is why I used a boolean type in the first version. Using an enum type does break this pattern, but it more clearly indicates whether it is idempotent or non-idempotent. Since I have created a Jira ticket to refactor this boolean value, both approaches seem less critical at this point. I have two solutions: one is to complete the refactoring work in that Jira ticket first and then finish this PR. The other is, if @mihaibudiu agrees to revert to using a boolean type, I can also roll back the code and complete this PR first.
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3394744114
This is not a ready PR, just a suggestion.
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on code in PR #4577:
URL: https://github.com/apache/calcite/pull/4577#discussion_r2429218234
##########
core/src/main/java/org/apache/calcite/sql/SqlBasicFunction.java:
##########
@@ -180,35 +195,40 @@ public static SqlBasicFunction create(String name,
return dynamic;
}
+ @Override public boolean isIdempotent() {
+ return idempotent;
+ }
+
/** Returns a copy of this function with a given name. */
public SqlBasicFunction withName(String name) {
return new SqlBasicFunction(name, kind, syntax, deterministic,
getReturnTypeInference(), getOperandTypeInference(), operandHandler,
getOperandTypeChecker(), callValidator,
- getFunctionType(), monotonicityInference, dynamic);
+ getFunctionType(), monotonicityInference, dynamic, idempotent);
Review Comment:
IMO a (new) boolean flag makes more sense considering the already existing flag (deterministic, dynamic). Modifying the constructors is the way to ensure backwards compatibility and avoid breaking consumers.
Whenever we tackle CALCITE-7224, we could deprecate all the constructors using the several flags (with the classic "to be removed before 2.0" comment), and create a single one with a unified flag field.
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3402625511
It's not really about niche and non-niche, in general the number of algebraic properties you may look for when optimizing is unbounded. It is not sustainable to modify all objects to represent such properties; that's exactly what the visitor pattern is designed to solve.
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on code in PR #4577:
URL: https://github.com/apache/calcite/pull/4577#discussion_r2427516746
##########
core/src/main/java/org/apache/calcite/sql/SqlBasicFunction.java:
##########
@@ -180,35 +195,40 @@ public static SqlBasicFunction create(String name,
return dynamic;
}
+ @Override public boolean isIdempotent() {
+ return idempotent;
+ }
+
/** Returns a copy of this function with a given name. */
public SqlBasicFunction withName(String name) {
return new SqlBasicFunction(name, kind, syntax, deterministic,
getReturnTypeInference(), getOperandTypeInference(), operandHandler,
getOperandTypeChecker(), callValidator,
- getFunctionType(), monotonicityInference, dynamic);
+ getFunctionType(), monotonicityInference, dynamic, idempotent);
Review Comment:
I added a new constructor and restored the previously modified create method. Is this the modification you meant?
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4577:
URL: https://github.com/apache/calcite/pull/4577#discussion_r2427525076
##########
core/src/main/java/org/apache/calcite/sql/SqlBasicFunction.java:
##########
@@ -180,35 +195,40 @@ public static SqlBasicFunction create(String name,
return dynamic;
}
+ @Override public boolean isIdempotent() {
+ return idempotent;
+ }
+
/** Returns a copy of this function with a given name. */
public SqlBasicFunction withName(String name) {
return new SqlBasicFunction(name, kind, syntax, deterministic,
getReturnTypeInference(), getOperandTypeInference(), operandHandler,
getOperandTypeChecker(), callValidator,
- getFunctionType(), monotonicityInference, dynamic);
+ getFunctionType(), monotonicityInference, dynamic, idempotent);
Review Comment:
yes
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3399381704
> Yes, I think that once you make them Boolean, you can't change them to something else. Let's see if anyone else has a different suggestion. People may not like a lot of tiny enum classes, but from my experience they are not too bad, and they provide very strong typing. In general, if you can wrap an abstraction, no matter how small, in a class, I think it's worth wrapping (unless performance is a concern).
I agree with your suggestion. Since refactoring may not happen immediately, we can first implement the new feature to an ideal state. I will later change it to an enum type.
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3394796659
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4577) **Quality Gate passed**
Issues
 [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4577&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4577&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4577&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [97.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4577&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4577&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4577)
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3403100997
You can leave the PR open and move the discussion to JIRA.
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3395445368
> Could be a valid approach. It's aligned with already existing aspects like "deterministic" and "dynamic". Maybe in the long run we could even consider combining these fields (`deterministic`, `dynamic`, `idempotent`, and any other that may come) into a single flag field instead of N booleans.
Yes, I think we can continue to integrate or refactor this later. The current PR is mainly intended to share an initial idea. If you'd like me to further improve it, please let me know — I'm not sure if the original author has time to continue working on their PR.
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3398535760
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4577) **Quality Gate passed**
Issues
 [1 New issue](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4577&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4577&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4577&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [97.8% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4577&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4577&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4577)
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on code in PR #4577:
URL: https://github.com/apache/calcite/pull/4577#discussion_r2427470717
##########
core/src/main/java/org/apache/calcite/sql/SqlBasicFunction.java:
##########
@@ -180,35 +195,40 @@ public static SqlBasicFunction create(String name,
return dynamic;
}
+ @Override public boolean isIdempotent() {
+ return idempotent;
+ }
+
/** Returns a copy of this function with a given name. */
public SqlBasicFunction withName(String name) {
return new SqlBasicFunction(name, kind, syntax, deterministic,
getReturnTypeInference(), getOperandTypeInference(), operandHandler,
getOperandTypeChecker(), callValidator,
- getFunctionType(), monotonicityInference, dynamic);
+ getFunctionType(), monotonicityInference, dynamic, idempotent);
Review Comment:
I didn't quite understand your comment. Here, a similar function to "copy" requires ensuring idempotency with previously set values.
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4577:
URL: https://github.com/apache/calcite/pull/4577#discussion_r2427476186
##########
core/src/main/java/org/apache/calcite/sql/SqlBasicFunction.java:
##########
@@ -180,35 +195,40 @@ public static SqlBasicFunction create(String name,
return dynamic;
}
+ @Override public boolean isIdempotent() {
+ return idempotent;
+ }
+
/** Returns a copy of this function with a given name. */
public SqlBasicFunction withName(String name) {
return new SqlBasicFunction(name, kind, syntax, deterministic,
getReturnTypeInference(), getOperandTypeInference(), operandHandler,
getOperandTypeChecker(), callValidator,
- getFunctionType(), monotonicityInference, dynamic);
+ getFunctionType(), monotonicityInference, dynamic, idempotent);
Review Comment:
I have several comments.
you have changed lots of constructor invocations.
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3399643080
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4577) **Quality Gate passed**
Issues
 [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4577&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4577&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4577&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [97.8% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4577&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4577&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4577)
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3397440028
I updated the test case and forced submission. It is currently in the ready state. If the original author continues his work, I will close this PR.
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu closed pull request #4577: [CALCITE-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP
URL: https://github.com/apache/calcite/pull/4577
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3403006387
> It's not really about niche and non-niche, in general the number of algebraic properties you may look for when optimizing is unbounded. It is not sustainable to modify all objects to represent such properties; that's exactly what the visitor pattern is designed to solve.
I think we might be discussing how to refactor the function attribute system, which seems unrelated to the purpose of this PR. Since using boolean types as attribute identifiers is already an existing practice, should we accept extending it in the same way? If our final conclusion is not to agree, this PR could be temporarily closed, and the discussion on refactoring function attributes could continue in the new Jira ticket. 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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4577:
URL: https://github.com/apache/calcite/pull/4577#discussion_r2426864842
##########
core/src/main/java/org/apache/calcite/sql/SqlBasicFunction.java:
##########
@@ -180,35 +195,40 @@ public static SqlBasicFunction create(String name,
return dynamic;
}
+ @Override public boolean isIdempotent() {
+ return idempotent;
+ }
+
/** Returns a copy of this function with a given name. */
public SqlBasicFunction withName(String name) {
return new SqlBasicFunction(name, kind, syntax, deterministic,
getReturnTypeInference(), getOperandTypeInference(), operandHandler,
getOperandTypeChecker(), callValidator,
- getFunctionType(), monotonicityInference, dynamic);
+ getFunctionType(), monotonicityInference, dynamic, idempotent);
Review Comment:
why not keep the constructor version with a default value of 'false' for this argument?
One alternative is to define a new `enum { IDEMPOTENT, NONIDEMPOTENT }` instead of using boolean.
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3399353538
> I have filed a jira [CALCITE-7224](https://issues.apache.org/jira/browse/CALCITE-7224)
I have filed a jira [CALCITE-7224](https://issues.apache.org/jira/browse/CALCITE-7224), and can be processed together with existing deterministic and dynamic follow-ups.
--
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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3399358344
Yes, I saw that, but that may require changing signatures for these 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-7122] Eliminate nested calls for idempotent unary functions UPPER/LOWER/ABS/INITCAP [calcite]
Posted by "xiedeyantu (via GitHub)" <gi...@apache.org>.
xiedeyantu commented on PR #4577:
URL: https://github.com/apache/calcite/pull/4577#issuecomment-3402479314
Hi @mihaibudiu, do you also think the function property of idempotency is too niche and not suitable for inclusion as a common property? If that is your point, I agree with your perspective. However, if we set aside its limited applicability, properties like determinism, dynamism, and monotonicity are already maintained as common attributes in this manner, so I believe this approach is reasonable.
--
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