You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "NobiGo (via GitHub)" <gi...@apache.org> on 2025/02/26 02:14:22 UTC
[PR] [CALCITE-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
NobiGo opened a new pull request, #4214:
URL: https://github.com/apache/calcite/pull/4214
…S NOT FALSE in StarRocksDialect
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2029553524
##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -166,8 +166,12 @@ public abstract class SqlImplementor {
protected final Map<CorrelationId, Context> correlTableMap = new HashMap<>();
- /** Private RexBuilder for short-lived expressions. It has its own
- * dedicated type factory, so don't trust the types to be canonized. */
+ /**
+ * Private RexBuilder for short-lived expressions. It has its own
+ * dedicated type factory, so don't trust the types to be canonized.
+ *
+ * @deprecated Replaced by {@link RexBuilder#DEFAULT}. */
+ @Deprecated // to be removed before 2.0
Review Comment:
This change is necessary. I tried to obtain `RexBuilder` through `implementer().RexBuilder`, but SimpleContext may throw UnsupportedOperaException in some 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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2025897472
##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -855,6 +855,76 @@ private SqlNode callToSql(@Nullable RexProgram program, RexCall call0,
final RexCall call = (RexCall) stripCastFromString(call1, dialect);
SqlOperator op = call.getOperator();
switch (op.getKind()) {
+ case IS_FALSE:
Review Comment:
Or we could change "supportsUnparseOnlyDeterministic" in the current PR to "supportsUnparsePartial" and mark it as @Experimental. Then we'll see if it's necessary to add the parsing of RexNode to Dialect later.
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo merged PR #4214:
URL: https://github.com/apache/calcite/pull/4214
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2021815026
##########
core/src/main/java/org/apache/calcite/sql/dialect/StarRocksSqlDialect.java:
##########
@@ -128,6 +132,72 @@ public StarRocksSqlDialect(Context context) {
timeUnitNode.getParserPosition());
SqlFloorFunction.unparseDatetimeFunction(writer, newCall, "DATE_TRUNC", false);
break;
+ case IS_TRUE:
+ if (this.supportMacroLikeUnparse()) {
Review Comment:
BTW: I have the impression that there are other places in Calcite where expressions are copied without concern for deterministic behavior.
##########
core/src/main/java/org/apache/calcite/sql/dialect/StarRocksSqlDialect.java:
##########
@@ -128,6 +132,72 @@ public StarRocksSqlDialect(Context context) {
timeUnitNode.getParserPosition());
SqlFloorFunction.unparseDatetimeFunction(writer, newCall, "DATE_TRUNC", false);
break;
+ case IS_TRUE:
+ if (this.supportMacroLikeUnparse()) {
Review Comment:
how about having a conservative approximation?
for example, you can have a shuttle which checks whether operand(0) invokes a non-deterministic function.
You can approximate that by "calls any function" for now.
Or the dialect could have a list of non-deterministic function names, there aren't that many.
##########
core/src/main/java/org/apache/calcite/sql/SqlDialect.java:
##########
@@ -795,6 +795,14 @@ public boolean supportBooleanCaseWhen() {
return true;
}
+ /**
+ * Returns whether to enable unparse of "macro-like" calls such as IS TRUE.
+ * "A IS TRUE" can be unparse to "A IS NOT NULL AND A" When A is deterministic.
+ * Otherwise, inconsistent results may occur. */
+ public boolean supportMacroLikeUnparse() {
Review Comment:
I don't understand how this fixes the problem of non-deterministic 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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r1970834025
##########
core/src/main/java/org/apache/calcite/sql/dialect/StarRocksSqlDialect.java:
##########
@@ -128,6 +132,52 @@ public StarRocksSqlDialect(Context context) {
timeUnitNode.getParserPosition());
SqlFloorFunction.unparseDatetimeFunction(writer, newCall, "DATE_TRUNC", false);
break;
+ case IS_TRUE:
Review Comment:
Perhaps we'll consider your suggestion later.
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2025834254
##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -855,6 +855,76 @@ private SqlNode callToSql(@Nullable RexProgram program, RexCall call0,
final RexCall call = (RexCall) stripCastFromString(call1, dialect);
SqlOperator op = call.getOperator();
switch (op.getKind()) {
+ case IS_FALSE:
Review Comment:
I have also been pondering over this for a long time. How can I accurately express it so that the developers can quickly figure out which functions should be added here and which ones should use unparseCall instead?
How about `unparseCallPartial` The meaning is that this function "unparse" is supported in certain scenarios, not in all 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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2023877782
##########
core/src/main/java/org/apache/calcite/sql/dialect/StarRocksSqlDialect.java:
##########
@@ -93,6 +94,18 @@ public StarRocksSqlDialect(Context context) {
return true;
}
+ @Override public boolean supportsUnparseOnlyDeterministic(SqlOperator sqlOperator) {
Review Comment:
If we do not support rewriting this function, we should throw exceptions at the point of rewriting. We directly convert it because only Starrocks has been identified to have this issue. If it is discovered later that operations like A IS TRUE and A IS NOT NULL are also unsupported, exceptions must be thrown during the conversion process. This conversion logic can be implemented as part of the Dialect behavior.
If I remove this function, the A IS FALSE will remain unchanged and not be converted.
What I'm thinking here is that not all dialects have undergone such transformation. If the database supports A IS TRUE, then we won't make any changes.
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r1970822627
##########
core/src/main/java/org/apache/calcite/sql/dialect/StarRocksSqlDialect.java:
##########
@@ -128,6 +132,52 @@ public StarRocksSqlDialect(Context context) {
timeUnitNode.getParserPosition());
SqlFloorFunction.unparseDatetimeFunction(writer, newCall, "DATE_TRUNC", false);
break;
+ case IS_TRUE:
Review Comment:
The only solution I can think of is more complicated: you need to add a new project saving the value of the expression, and then do the expansion for that value.
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2021975089
##########
core/src/main/java/org/apache/calcite/sql/dialect/StarRocksSqlDialect.java:
##########
@@ -128,6 +132,72 @@ public StarRocksSqlDialect(Context context) {
timeUnitNode.getParserPosition());
SqlFloorFunction.unparseDatetimeFunction(writer, newCall, "DATE_TRUNC", false);
break;
+ case IS_TRUE:
+ if (this.supportMacroLikeUnparse()) {
Review Comment:
We already have RexUtil#isDeterministic for detecting whether a function is deterministic. Currently, what I'm thinking is that only when there is a transformation similar to "IS TRUE", where a reference becomes multiple times, will it lead to inconsistent results. Functions like COALESCE and NULLIF fall into this category.
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "suibianwanwank (via GitHub)" <gi...@apache.org>.
suibianwanwank commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2023002422
##########
core/src/main/java/org/apache/calcite/sql/dialect/StarRocksSqlDialect.java:
##########
@@ -128,6 +132,72 @@ public StarRocksSqlDialect(Context context) {
timeUnitNode.getParserPosition());
SqlFloorFunction.unparseDatetimeFunction(writer, newCall, "DATE_TRUNC", false);
break;
+ case IS_TRUE:
+ if (this.supportMacroLikeUnparse()) {
Review Comment:
I agree, any scenario requiring splitting a rexNode into multiple processing paths would encounter this problem. But it seems difficult to resolve at the root cause - the only solution I can think of is to specially handle it by adding an additional Project whenever this situation occurs.
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4214:
URL: https://github.com/apache/calcite/pull/4214#issuecomment-2770205256
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4214) **Quality Gate passed**
Issues
 [1 New issue](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4214&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4214&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4214&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [97.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4214&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4214&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4214)
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2025825068
##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -855,6 +855,76 @@ private SqlNode callToSql(@Nullable RexProgram program, RexCall call0,
final RexCall call = (RexCall) stripCastFromString(call1, dialect);
SqlOperator op = call.getOperator();
switch (op.getKind()) {
+ case IS_FALSE:
Review Comment:
true.
I don't really like this function "supportsUnparseOnlyDeterministic()", because it really has nothing to do with IS_TRUE, etc. But I don't have a better proposal on how to structure this.
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2025857071
##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -855,6 +855,76 @@ private SqlNode callToSql(@Nullable RexProgram program, RexCall call0,
final RexCall call = (RexCall) stripCastFromString(call1, dialect);
SqlOperator op = call.getOperator();
switch (op.getKind()) {
+ case IS_FALSE:
Review Comment:
I understand. I will try to do it this way.
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4214:
URL: https://github.com/apache/calcite/pull/4214#issuecomment-2781807543
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4214) **Quality Gate passed**
Issues
 [12 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4214&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4214&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4214&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4214&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4214&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4214)
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2027917042
##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -166,8 +166,12 @@ public abstract class SqlImplementor {
protected final Map<CorrelationId, Context> correlTableMap = new HashMap<>();
- /** Private RexBuilder for short-lived expressions. It has its own
- * dedicated type factory, so don't trust the types to be canonized. */
+ /**
+ * Private RexBuilder for short-lived expressions. It has its own
+ * dedicated type factory, so don't trust the types to be canonized.
+ *
+ * @deprecated Replaced by {@link RexBuilder#DEFAULT}. */
+ @Deprecated // to be removed before 2.0
Review Comment:
I am not sure about this change, though
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r1970811816
##########
core/src/main/java/org/apache/calcite/sql/dialect/StarRocksSqlDialect.java:
##########
@@ -128,6 +132,52 @@ public StarRocksSqlDialect(Context context) {
timeUnitNode.getParserPosition());
SqlFloorFunction.unparseDatetimeFunction(writer, newCall, "DATE_TRUNC", false);
break;
+ case IS_TRUE:
Review Comment:
this won't work if the expression has side effects, e.g., the function is RAND().
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2021962769
##########
core/src/main/java/org/apache/calcite/sql/SqlDialect.java:
##########
@@ -795,6 +795,14 @@ public boolean supportBooleanCaseWhen() {
return true;
}
+ /**
+ * Returns whether to enable unparse of "macro-like" calls such as IS TRUE.
+ * "A IS TRUE" can be unparse to "A IS NOT NULL AND A" When A is deterministic.
+ * Otherwise, inconsistent results may occur. */
+ public boolean supportMacroLikeUnparse() {
Review Comment:
Ok. This approach is somewhat inappropriate.
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2025839328
##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -855,6 +855,76 @@ private SqlNode callToSql(@Nullable RexProgram program, RexCall call0,
final RexCall call = (RexCall) stripCastFromString(call1, dialect);
SqlOperator op = call.getOperator();
switch (op.getKind()) {
+ case IS_FALSE:
Review Comment:
The most generic way to handle this would be to add a hook in the dialect to rewrite calls before they are converted to sql. This hook would be called from callToSql prior to converting to SqlNode.
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4214:
URL: https://github.com/apache/calcite/pull/4214#issuecomment-2770840412
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4214) **Quality Gate passed**
Issues
 [5 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4214&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4214&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4214&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [94.4% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4214&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4214&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4214)
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2023771920
##########
core/src/main/java/org/apache/calcite/sql/dialect/StarRocksSqlDialect.java:
##########
@@ -128,6 +132,72 @@ public StarRocksSqlDialect(Context context) {
timeUnitNode.getParserPosition());
SqlFloorFunction.unparseDatetimeFunction(writer, newCall, "DATE_TRUNC", false);
break;
+ case IS_TRUE:
+ if (this.supportMacroLikeUnparse()) {
Review Comment:
I've revised the PR according to the feedback. When you have time, please review the updates.
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2021963077
##########
core/src/main/java/org/apache/calcite/sql/dialect/StarRocksSqlDialect.java:
##########
@@ -128,6 +132,72 @@ public StarRocksSqlDialect(Context context) {
timeUnitNode.getParserPosition());
SqlFloorFunction.unparseDatetimeFunction(writer, newCall, "DATE_TRUNC", false);
break;
+ case IS_TRUE:
+ if (this.supportMacroLikeUnparse()) {
Review Comment:
This is probably not the only place where a rewrite could be wrong if a call is not deterministic. I think it would be a useful feature to be able to detect such calls.
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2025961346
##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -855,6 +855,76 @@ private SqlNode callToSql(@Nullable RexProgram program, RexCall call0,
final RexCall call = (RexCall) stripCastFromString(call1, dialect);
SqlOperator op = call.getOperator();
switch (op.getKind()) {
+ case IS_FALSE:
Review Comment:
I am thinking of a function in Dialect like this: `RexCall prepareUnparse(RexCall arg)` which can rewrite a RexCall before it is unparsed; the default implementation returns arg. The argument could be RexNode too.
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2029557949
##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -166,8 +166,12 @@ public abstract class SqlImplementor {
protected final Map<CorrelationId, Context> correlTableMap = new HashMap<>();
- /** Private RexBuilder for short-lived expressions. It has its own
- * dedicated type factory, so don't trust the types to be canonized. */
+ /**
+ * Private RexBuilder for short-lived expressions. It has its own
+ * dedicated type factory, so don't trust the types to be canonized.
+ *
+ * @deprecated Replaced by {@link RexBuilder#DEFAULT}. */
+ @Deprecated // to be removed before 2.0
Review Comment:
I am concerned that other projects have implemented this interface and obtained this RexBuilder instance through `implementer(). RexBuilder`.We don't need it anymore. To maintain compatibility, I added @ Deprecated.
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4214:
URL: https://github.com/apache/calcite/pull/4214#issuecomment-2775503909
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4214) **Quality Gate passed**
Issues
 [12 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4214&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4214&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4214&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4214&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4214&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4214)
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #4214:
URL: https://github.com/apache/calcite/pull/4214#issuecomment-2775513154
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4214) **Quality Gate passed**
Issues
 [12 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4214&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=4214&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=4214&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4214&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=4214&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=4214)
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r1970821560
##########
core/src/main/java/org/apache/calcite/sql/dialect/StarRocksSqlDialect.java:
##########
@@ -128,6 +132,52 @@ public StarRocksSqlDialect(Context context) {
timeUnitNode.getParserPosition());
SqlFloorFunction.unparseDatetimeFunction(writer, newCall, "DATE_TRUNC", false);
break;
+ case IS_TRUE:
Review Comment:
Good catch. I overlooked this non-deterministic expression. If this expression is non-deterministic, I will throw an exception. Or do you have any other more general approaches for handling this situation?
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2025815556
##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -855,6 +855,76 @@ private SqlNode callToSql(@Nullable RexProgram program, RexCall call0,
final RexCall call = (RexCall) stripCastFromString(call1, dialect);
SqlOperator op = call.getOperator();
switch (op.getKind()) {
+ case IS_FALSE:
Review Comment:
If we use unparseCall, we need to parse the SqlCall. We can't extract whether it is deterministic from SqlCall. So, I put it here.
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2025893226
##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -855,6 +855,76 @@ private SqlNode callToSql(@Nullable RexProgram program, RexCall call0,
final RexCall call = (RexCall) stripCastFromString(call1, dialect);
SqlOperator op = call.getOperator();
switch (op.getKind()) {
+ case IS_FALSE:
Review Comment:
Adding RexNode parsing to Dialect might render the current unparseCall ineffective. After all, RexNode offers greater flexibility.
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2025275100
##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -855,6 +855,76 @@ private SqlNode callToSql(@Nullable RexProgram program, RexCall call0,
final RexCall call = (RexCall) stripCastFromString(call1, dialect);
SqlOperator op = call.getOperator();
switch (op.getKind()) {
+ case IS_FALSE:
Review Comment:
Can this be done in unparseCall instead?
Then you don't need the new policy function.
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2025878753
##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -855,6 +855,76 @@ private SqlNode callToSql(@Nullable RexProgram program, RexCall call0,
final RexCall call = (RexCall) stripCastFromString(call1, dialect);
SqlOperator op = call.getOperator();
switch (op.getKind()) {
+ case IS_FALSE:
Review Comment:
the only misgivings I have about that is that the Dialect class is mostly about SqlNode.
But it does have a method that takes a RexNode
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2021953640
##########
core/src/main/java/org/apache/calcite/sql/SqlDialect.java:
##########
@@ -795,6 +795,14 @@ public boolean supportBooleanCaseWhen() {
return true;
}
+ /**
+ * Returns whether to enable unparse of "macro-like" calls such as IS TRUE.
+ * "A IS TRUE" can be unparse to "A IS NOT NULL AND A" When A is deterministic.
+ * Otherwise, inconsistent results may occur. */
+ public boolean supportMacroLikeUnparse() {
Review Comment:
This has not been fixed. It would be more accurate to say that it is a kind of compatible approach, which refers to SqlValidator#withCallRewrite.
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r1970833333
##########
core/src/main/java/org/apache/calcite/sql/dialect/StarRocksSqlDialect.java:
##########
@@ -128,6 +132,52 @@ public StarRocksSqlDialect(Context context) {
timeUnitNode.getParserPosition());
SqlFloorFunction.unparseDatetimeFunction(writer, newCall, "DATE_TRUNC", false);
break;
+ case IS_TRUE:
Review Comment:
Ok, I understand your approach. For this PR, I will throw an exception for non-deterministic expressions.
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #4214:
URL: https://github.com/apache/calcite/pull/4214#issuecomment-2760101636
This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 90 days if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@calcite.apache.org list. Thank you for your contributions.
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "NobiGo (via GitHub)" <gi...@apache.org>.
NobiGo commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2021960638
##########
core/src/main/java/org/apache/calcite/sql/dialect/StarRocksSqlDialect.java:
##########
@@ -128,6 +132,72 @@ public StarRocksSqlDialect(Context context) {
timeUnitNode.getParserPosition());
SqlFloorFunction.unparseDatetimeFunction(writer, newCall, "DATE_TRUNC", false);
break;
+ case IS_TRUE:
+ if (this.supportMacroLikeUnparse()) {
Review Comment:
My current approach is indeed a bit strange. Since this might not be within the purview of SqlDialect, in StarRocksSqlDialect, it is not certain whether this function is deterministic(SqlCall). If we make this judgment in SqlImplementor, we need a list of unsupported functions to determine whether to rewrite it. This list is used to write functions that Dialect does not support and which might be non-deterministic. WDYT?
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2021958515
##########
core/src/main/java/org/apache/calcite/sql/SqlDialect.java:
##########
@@ -795,6 +795,14 @@ public boolean supportBooleanCaseWhen() {
return true;
}
+ /**
+ * Returns whether to enable unparse of "macro-like" calls such as IS TRUE.
+ * "A IS TRUE" can be unparse to "A IS NOT NULL AND A" When A is deterministic.
+ * Otherwise, inconsistent results may occur. */
+ public boolean supportMacroLikeUnparse() {
Review Comment:
I think this is not really necessary then.
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2021975777
##########
core/src/main/java/org/apache/calcite/sql/dialect/StarRocksSqlDialect.java:
##########
@@ -128,6 +132,72 @@ public StarRocksSqlDialect(Context context) {
timeUnitNode.getParserPosition());
SqlFloorFunction.unparseDatetimeFunction(writer, newCall, "DATE_TRUNC", false);
break;
+ case IS_TRUE:
+ if (this.supportMacroLikeUnparse()) {
Review Comment:
Right
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2023859035
##########
core/src/main/java/org/apache/calcite/sql/dialect/StarRocksSqlDialect.java:
##########
@@ -93,6 +94,18 @@ public StarRocksSqlDialect(Context context) {
return true;
}
+ @Override public boolean supportsUnparseOnlyDeterministic(SqlOperator sqlOperator) {
Review Comment:
I am not sure this function is useful.
If the function returns 'false' and you cannot unparse, you will need to throw.
If you remove the function, you still throw in the same places.
--
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-6835] Invalid unparse for IS TRUE,IS FALSE,IS NOT TRUE and I… [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #4214:
URL: https://github.com/apache/calcite/pull/4214#discussion_r2029555364
##########
core/src/main/java/org/apache/calcite/rel/rel2sql/SqlImplementor.java:
##########
@@ -166,8 +166,12 @@ public abstract class SqlImplementor {
protected final Map<CorrelationId, Context> correlTableMap = new HashMap<>();
- /** Private RexBuilder for short-lived expressions. It has its own
- * dedicated type factory, so don't trust the types to be canonized. */
+ /**
+ * Private RexBuilder for short-lived expressions. It has its own
+ * dedicated type factory, so don't trust the types to be canonized.
+ *
+ * @deprecated Replaced by {@link RexBuilder#DEFAULT}. */
+ @Deprecated // to be removed before 2.0
Review Comment:
Well, I approved the PR.
But it would be good to know why this method needs to be essentially deprecated (because it can't be used).
--
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