You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "caicancai (via GitHub)" <gi...@apache.org> on 2024/05/03 13:16:40 UTC
[PR] [CALCITE-6397] Add NVL2 function (enabled in Spark library) [calcite]
caicancai opened a new pull request, #3785:
URL: https://github.com/apache/calcite/pull/3785
(no comment)
--
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-6397] Add NVL2 function (enabled in Oracle, Spark library) [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1600522936
##########
core/src/main/java/org/apache/calcite/sql/type/ReturnTypes.java:
##########
@@ -551,6 +551,13 @@ public static SqlCall stripSeparator(SqlCall call) {
opBinding -> opBinding.getTypeFactory().leastRestrictive(
opBinding.collectOperandTypes());
+ public static final SqlReturnTypeInference NVL2_RESTRICTIVE = opBinding -> {
Review Comment:
This looks wrong. If the first operand does not have the type null then you need to unify the types of operands 2 and 3. In fact, I think you always need to unify them.
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1597579306
##########
core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java:
##########
@@ -418,6 +419,32 @@ private static RexNode convertNvl(SqlRexContext cx, SqlCall call) {
operand1)));
}
+ /** Converts a call to the {@code NVL2} function. */
+ private static RexNode convertNvl2(SqlRexContext cx, SqlCall call) {
+ final RexBuilder rexBuilder = cx.getRexBuilder();
+ final RexNode operand0 =
+ cx.convertExpression(call.getOperandList().get(0));
+ final RexNode operand1 =
+ cx.convertExpression(call.getOperandList().get(1));
+ final RexNode operand2 =
+ cx.convertExpression(call.getOperandList().get(2));
+ final RelDataType type =
+ cx.getValidator().getValidatedNodeType(call);
+ // Preserve Operand Nullability
Review Comment:
Thanks for the teaching, done
##########
core/src/main/java/org/apache/calcite/sql/type/ReturnTypes.java:
##########
@@ -551,6 +551,13 @@ public static SqlCall stripSeparator(SqlCall call) {
opBinding -> opBinding.getTypeFactory().leastRestrictive(
opBinding.collectOperandTypes());
+ public static final SqlReturnTypeInference NVL2_RESTRICTIVE = opBinding -> {
+ RelDataType opType1 = opBinding.getOperandType(1);
+ RelDataType opType2 = opBinding.getOperandType(2);
+ return opBinding.getOperandType(0).getSqlTypeName() == SqlTypeName.NULL ? opType2 : opType1;
+ };
+
+
Review Comment:
done
--
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-6397] Add NVL2 function (enabled in Oracle, Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on PR #3785:
URL: https://github.com/apache/calcite/pull/3785#issuecomment-2141399389
@mihaibudiu @julianhyde @YiwenWu
Thanks for the review, squashed
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1597579143
##########
core/src/main/java/org/apache/calcite/sql/type/ReturnTypes.java:
##########
@@ -551,6 +551,13 @@ public static SqlCall stripSeparator(SqlCall call) {
opBinding -> opBinding.getTypeFactory().leastRestrictive(
opBinding.collectOperandTypes());
+ public static final SqlReturnTypeInference NVL2_RESTRICTIVE = opBinding -> {
Review Comment:
done
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1596920047
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -10036,6 +10036,45 @@ void assertSubFunReturns(boolean binary, String s, int start,
checkNvl(f, FunctionAlias.of(SqlLibraryOperators.NVL));
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6397">[CALCITE-6397]
+ * Add NVL2 function (enabled in Spark library). </a>.
+ */
+ @Test void testNvl2Func() {
+ final SqlOperatorFixture f = fixture();
+ f.setFor(SqlLibraryOperators.NVL2, VmName.EXPAND);
+ f.checkFails("^nvl2(NULL, 2, 1)^",
+ "No match found for function signature "
+ + "NVL2\\(<NULL>, <NUMERIC>, <NUMERIC>\\)", false);
+
+ final SqlOperatorFixture f12 = f
+ .withLibrary(SqlLibrary.SPARK);
+ f12.checkScalar("nvl2(NULL, 2, 1)", "1", "INTEGER NOT NULL");
+ f12.checkScalar("nvl2(true, true, false)", true, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(false, true, false)", true, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(NULL, true, false)", false, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(3, 2, 1)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("nvl2(3, 'a', 'b')", "a", "CHAR(1) NOT NULL");
+ f12.checkScalar("nvl2(NULL, 'a', 'b')", "b", "CHAR(1) NOT NULL");
+ f12.checkScalar("nvl2(NULL, 'ab', 'de')", "de", "CHAR(2) NOT NULL");
+ f12.checkScalar("nvl2('ab', 'abc', 'def')", "abc", "CHAR(3) NOT NULL");
+ f12.checkScalar("nvl2('a', 3, 2)", "3", "INTEGER NOT NULL");
+
+ // check operand 1 and operand 2 are inconsistent
+ f12.checkScalar("NVL2(2.0, 'abc', 2)", "abc", "CHAR(3) NOT NULL");
+ f12.checkScalar("NVL2(NULL, 'abc', 2)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("NVL2(NULL, 3.0, 4.0)", "4.0", "DECIMAL(2, 1) NOT NULL");
+ f12.checkScalar("NVL2(NULL, 'abc', 2)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("NVL2('abc', 3.0, 4.0)", "3.0", "DECIMAL(2, 1) NOT NULL");
+ f12.checkScalar("NVL2(1, 3.0, 'abc')", "3.0", "DECIMAL(2, 1) NOT NULL");
+ f12.checkScalar("NVL2(NULL, 3.0, 'abc')", "abc", "CHAR(3) NOT NULL");
+
+ f12.checkNull("nvl2('ab', CAST(NULL AS VARCHAR(6)), 'def')");
+ f12.checkNull("nvl2(NULL, 'abc', NULL)");
+ f12.checkNull("nvl2(NULL, NULL, NULL)");
Review Comment:
@mihaibudiu Hello, sorry for replying so late. I found a problem.
NVL2 (2.0, 'abc', true) is allowed in type verification on calcite. The string type and the Boolean type are comparable. I am not sure about this. According to my understanding, it is not allowed. This is also not allowed in spark.
Should I modify the SameOperatndTypeChecker method
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1596942382
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -10036,6 +10036,45 @@ void assertSubFunReturns(boolean binary, String s, int start,
checkNvl(f, FunctionAlias.of(SqlLibraryOperators.NVL));
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6397">[CALCITE-6397]
+ * Add NVL2 function (enabled in Spark library). </a>.
+ */
+ @Test void testNvl2Func() {
+ final SqlOperatorFixture f = fixture();
+ f.setFor(SqlLibraryOperators.NVL2, VmName.EXPAND);
+ f.checkFails("^nvl2(NULL, 2, 1)^",
+ "No match found for function signature "
+ + "NVL2\\(<NULL>, <NUMERIC>, <NUMERIC>\\)", false);
+
+ final SqlOperatorFixture f12 = f
+ .withLibrary(SqlLibrary.SPARK);
+ f12.checkScalar("nvl2(NULL, 2, 1)", "1", "INTEGER NOT NULL");
+ f12.checkScalar("nvl2(true, true, false)", true, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(false, true, false)", true, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(NULL, true, false)", false, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(3, 2, 1)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("nvl2(3, 'a', 'b')", "a", "CHAR(1) NOT NULL");
+ f12.checkScalar("nvl2(NULL, 'a', 'b')", "b", "CHAR(1) NOT NULL");
+ f12.checkScalar("nvl2(NULL, 'ab', 'de')", "de", "CHAR(2) NOT NULL");
+ f12.checkScalar("nvl2('ab', 'abc', 'def')", "abc", "CHAR(3) NOT NULL");
+ f12.checkScalar("nvl2('a', 3, 2)", "3", "INTEGER NOT NULL");
+
+ // check operand 1 and operand 2 are inconsistent
+ f12.checkScalar("NVL2(2.0, 'abc', 2)", "abc", "CHAR(3) NOT NULL");
+ f12.checkScalar("NVL2(NULL, 'abc', 2)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("NVL2(NULL, 3.0, 4.0)", "4.0", "DECIMAL(2, 1) NOT NULL");
+ f12.checkScalar("NVL2(NULL, 'abc', 2)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("NVL2('abc', 3.0, 4.0)", "3.0", "DECIMAL(2, 1) NOT NULL");
+ f12.checkScalar("NVL2(1, 3.0, 'abc')", "3.0", "DECIMAL(2, 1) NOT NULL");
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1592619944
##########
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##########
@@ -986,6 +986,14 @@ public static SqlSingleOperandTypeChecker same(int operandCount,
public static final SqlSingleOperandTypeChecker ANY_ANY =
family(SqlTypeFamily.ANY, SqlTypeFamily.ANY);
+
+ public static final SqlSingleOperandTypeChecker SECOND_THIRD_SAME =
+ new SameOperandTypeChecker(3) {
Review Comment:
I think I understand what you mean, like nvl2(2.0, 'abc', 2) is allowed in spark, but
nvl2(2.0, true, 2) is not allowed because Boolean and numeric are not comparable
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1592622981
##########
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##########
@@ -986,6 +986,14 @@ public static SqlSingleOperandTypeChecker same(int operandCount,
public static final SqlSingleOperandTypeChecker ANY_ANY =
family(SqlTypeFamily.ANY, SqlTypeFamily.ANY);
+
+ public static final SqlSingleOperandTypeChecker SECOND_THIRD_SAME =
+ new SameOperandTypeChecker(3) {
Review Comment:
This is also the case with calcite currently. I have tested 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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3785:
URL: https://github.com/apache/calcite/pull/3785#issuecomment-2094100907
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3785) **Quality Gate passed**
Issues
 [23 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3785&resolved=false&inNewCodePeriod=true)
 [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3785&metric=new_accepted_issues&view=list)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3785&resolved=false&inNewCodePeriod=true)
 [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3785&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3785&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3785)
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3785:
URL: https://github.com/apache/calcite/pull/3785#issuecomment-2106181478
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3785) **Quality Gate passed**
Issues
 [1 New issue](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3785&resolved=false&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3785&metric=new_accepted_issues&view=list)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3785&resolved=false&sinceLeakPeriod=true)
 [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3785&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3785&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3785)
--
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-6397] Add NVL2 function (enabled in Oracle, Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1619142488
##########
core/src/main/java/org/apache/calcite/sql/SqlKind.java:
##########
@@ -421,9 +421,12 @@ public enum SqlKind {
/** {@code DECODE} function (Oracle). */
DECODE,
- /** {@code NVL} function (Oracle). */
+ /** {@code NVL} function (Oracle, Spark). */
NVL,
+ /** {@code NVL2} function (Oracle). */
Review Comment:
done
--
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-6397] Add NVL2 function (enabled in Oracle, Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on PR #3785:
URL: https://github.com/apache/calcite/pull/3785#issuecomment-2136377502
@YiwenWu If you have time, can you help me take a look at this PR? Thank you
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1592850739
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -10036,6 +10036,45 @@ void assertSubFunReturns(boolean binary, String s, int start,
checkNvl(f, FunctionAlias.of(SqlLibraryOperators.NVL));
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6397">[CALCITE-6397]
+ * Add NVL2 function (enabled in Spark library). </a>.
+ */
+ @Test void testNvl2Func() {
+ final SqlOperatorFixture f = fixture();
+ f.setFor(SqlLibraryOperators.NVL2, VmName.EXPAND);
+ f.checkFails("^nvl2(NULL, 2, 1)^",
+ "No match found for function signature "
+ + "NVL2\\(<NULL>, <NUMERIC>, <NUMERIC>\\)", false);
+
+ final SqlOperatorFixture f12 = f
+ .withLibrary(SqlLibrary.SPARK);
+ f12.checkScalar("nvl2(NULL, 2, 1)", "1", "INTEGER NOT NULL");
+ f12.checkScalar("nvl2(true, true, false)", true, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(false, true, false)", true, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(NULL, true, false)", false, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(3, 2, 1)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("nvl2(3, 'a', 'b')", "a", "CHAR(1) NOT NULL");
+ f12.checkScalar("nvl2(NULL, 'a', 'b')", "b", "CHAR(1) NOT NULL");
+ f12.checkScalar("nvl2(NULL, 'ab', 'de')", "de", "CHAR(2) NOT NULL");
+ f12.checkScalar("nvl2('ab', 'abc', 'def')", "abc", "CHAR(3) NOT NULL");
+ f12.checkScalar("nvl2('a', 3, 2)", "3", "INTEGER NOT NULL");
+
+ // check operand 1 and operand 2 are inconsistent
+ f12.checkScalar("NVL2(2.0, 'abc', 2)", "abc", "CHAR(3) NOT NULL");
+ f12.checkScalar("NVL2(NULL, 'abc', 2)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("NVL2(NULL, 3.0, 4.0)", "4.0", "DECIMAL(2, 1) NOT NULL");
+ f12.checkScalar("NVL2(NULL, 'abc', 2)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("NVL2('abc', 3.0, 4.0)", "3.0", "DECIMAL(2, 1) NOT NULL");
+ f12.checkScalar("NVL2(1, 3.0, 'abc')", "3.0", "DECIMAL(2, 1) NOT NULL");
Review Comment:
I assume you have checked these against Spark.
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -10036,6 +10036,45 @@ void assertSubFunReturns(boolean binary, String s, int start,
checkNvl(f, FunctionAlias.of(SqlLibraryOperators.NVL));
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6397">[CALCITE-6397]
+ * Add NVL2 function (enabled in Spark library). </a>.
+ */
+ @Test void testNvl2Func() {
+ final SqlOperatorFixture f = fixture();
+ f.setFor(SqlLibraryOperators.NVL2, VmName.EXPAND);
+ f.checkFails("^nvl2(NULL, 2, 1)^",
+ "No match found for function signature "
+ + "NVL2\\(<NULL>, <NUMERIC>, <NUMERIC>\\)", false);
+
+ final SqlOperatorFixture f12 = f
+ .withLibrary(SqlLibrary.SPARK);
+ f12.checkScalar("nvl2(NULL, 2, 1)", "1", "INTEGER NOT NULL");
+ f12.checkScalar("nvl2(true, true, false)", true, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(false, true, false)", true, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(NULL, true, false)", false, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(3, 2, 1)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("nvl2(3, 'a', 'b')", "a", "CHAR(1) NOT NULL");
+ f12.checkScalar("nvl2(NULL, 'a', 'b')", "b", "CHAR(1) NOT NULL");
+ f12.checkScalar("nvl2(NULL, 'ab', 'de')", "de", "CHAR(2) NOT NULL");
+ f12.checkScalar("nvl2('ab', 'abc', 'def')", "abc", "CHAR(3) NOT NULL");
+ f12.checkScalar("nvl2('a', 3, 2)", "3", "INTEGER NOT NULL");
+
+ // check operand 1 and operand 2 are inconsistent
+ f12.checkScalar("NVL2(2.0, 'abc', 2)", "abc", "CHAR(3) NOT NULL");
+ f12.checkScalar("NVL2(NULL, 'abc', 2)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("NVL2(NULL, 3.0, 4.0)", "4.0", "DECIMAL(2, 1) NOT NULL");
+ f12.checkScalar("NVL2(NULL, 'abc', 2)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("NVL2('abc', 3.0, 4.0)", "3.0", "DECIMAL(2, 1) NOT NULL");
+ f12.checkScalar("NVL2(1, 3.0, 'abc')", "3.0", "DECIMAL(2, 1) NOT NULL");
+ f12.checkScalar("NVL2(NULL, 3.0, 'abc')", "abc", "CHAR(3) NOT NULL");
+
+ f12.checkNull("nvl2('ab', CAST(NULL AS VARCHAR(6)), 'def')");
+ f12.checkNull("nvl2(NULL, 'abc', NULL)");
+ f12.checkNull("nvl2(NULL, NULL, NULL)");
Review Comment:
Can you add a few tests that fail in compilation as well because they don't typecheck?
Ideally these would also fail in Spark.
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1596920047
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -10036,6 +10036,45 @@ void assertSubFunReturns(boolean binary, String s, int start,
checkNvl(f, FunctionAlias.of(SqlLibraryOperators.NVL));
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6397">[CALCITE-6397]
+ * Add NVL2 function (enabled in Spark library). </a>.
+ */
+ @Test void testNvl2Func() {
+ final SqlOperatorFixture f = fixture();
+ f.setFor(SqlLibraryOperators.NVL2, VmName.EXPAND);
+ f.checkFails("^nvl2(NULL, 2, 1)^",
+ "No match found for function signature "
+ + "NVL2\\(<NULL>, <NUMERIC>, <NUMERIC>\\)", false);
+
+ final SqlOperatorFixture f12 = f
+ .withLibrary(SqlLibrary.SPARK);
+ f12.checkScalar("nvl2(NULL, 2, 1)", "1", "INTEGER NOT NULL");
+ f12.checkScalar("nvl2(true, true, false)", true, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(false, true, false)", true, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(NULL, true, false)", false, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(3, 2, 1)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("nvl2(3, 'a', 'b')", "a", "CHAR(1) NOT NULL");
+ f12.checkScalar("nvl2(NULL, 'a', 'b')", "b", "CHAR(1) NOT NULL");
+ f12.checkScalar("nvl2(NULL, 'ab', 'de')", "de", "CHAR(2) NOT NULL");
+ f12.checkScalar("nvl2('ab', 'abc', 'def')", "abc", "CHAR(3) NOT NULL");
+ f12.checkScalar("nvl2('a', 3, 2)", "3", "INTEGER NOT NULL");
+
+ // check operand 1 and operand 2 are inconsistent
+ f12.checkScalar("NVL2(2.0, 'abc', 2)", "abc", "CHAR(3) NOT NULL");
+ f12.checkScalar("NVL2(NULL, 'abc', 2)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("NVL2(NULL, 3.0, 4.0)", "4.0", "DECIMAL(2, 1) NOT NULL");
+ f12.checkScalar("NVL2(NULL, 'abc', 2)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("NVL2('abc', 3.0, 4.0)", "3.0", "DECIMAL(2, 1) NOT NULL");
+ f12.checkScalar("NVL2(1, 3.0, 'abc')", "3.0", "DECIMAL(2, 1) NOT NULL");
+ f12.checkScalar("NVL2(NULL, 3.0, 'abc')", "abc", "CHAR(3) NOT NULL");
+
+ f12.checkNull("nvl2('ab', CAST(NULL AS VARCHAR(6)), 'def')");
+ f12.checkNull("nvl2(NULL, 'abc', NULL)");
+ f12.checkNull("nvl2(NULL, NULL, NULL)");
Review Comment:
@mihaibudiu Hello, sorry for replying so late. I found a problem.
NVL2 (2.0, 'abc', true) is allowed in type verification on calcite. The string type and the Boolean type are comparable. I am not sure about this. According to my understanding, it is not allowed. This is also not allowed in spark.
Should I modify the SameOperatndTypeChecker method
--
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-6397] Add NVL2 function (enabled in Oracle, Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on PR #3785:
URL: https://github.com/apache/calcite/pull/3785#issuecomment-2107959410
@mihaibudiu Hello, I opened jira to discuss the comparability of character and boolean types because I'm not sure if this is a bug.
https://issues.apache.org/jira/browse/CALCITE-6409
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1596920047
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -10036,6 +10036,45 @@ void assertSubFunReturns(boolean binary, String s, int start,
checkNvl(f, FunctionAlias.of(SqlLibraryOperators.NVL));
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6397">[CALCITE-6397]
+ * Add NVL2 function (enabled in Spark library). </a>.
+ */
+ @Test void testNvl2Func() {
+ final SqlOperatorFixture f = fixture();
+ f.setFor(SqlLibraryOperators.NVL2, VmName.EXPAND);
+ f.checkFails("^nvl2(NULL, 2, 1)^",
+ "No match found for function signature "
+ + "NVL2\\(<NULL>, <NUMERIC>, <NUMERIC>\\)", false);
+
+ final SqlOperatorFixture f12 = f
+ .withLibrary(SqlLibrary.SPARK);
+ f12.checkScalar("nvl2(NULL, 2, 1)", "1", "INTEGER NOT NULL");
+ f12.checkScalar("nvl2(true, true, false)", true, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(false, true, false)", true, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(NULL, true, false)", false, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(3, 2, 1)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("nvl2(3, 'a', 'b')", "a", "CHAR(1) NOT NULL");
+ f12.checkScalar("nvl2(NULL, 'a', 'b')", "b", "CHAR(1) NOT NULL");
+ f12.checkScalar("nvl2(NULL, 'ab', 'de')", "de", "CHAR(2) NOT NULL");
+ f12.checkScalar("nvl2('ab', 'abc', 'def')", "abc", "CHAR(3) NOT NULL");
+ f12.checkScalar("nvl2('a', 3, 2)", "3", "INTEGER NOT NULL");
+
+ // check operand 1 and operand 2 are inconsistent
+ f12.checkScalar("NVL2(2.0, 'abc', 2)", "abc", "CHAR(3) NOT NULL");
+ f12.checkScalar("NVL2(NULL, 'abc', 2)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("NVL2(NULL, 3.0, 4.0)", "4.0", "DECIMAL(2, 1) NOT NULL");
+ f12.checkScalar("NVL2(NULL, 'abc', 2)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("NVL2('abc', 3.0, 4.0)", "3.0", "DECIMAL(2, 1) NOT NULL");
+ f12.checkScalar("NVL2(1, 3.0, 'abc')", "3.0", "DECIMAL(2, 1) NOT NULL");
+ f12.checkScalar("NVL2(NULL, 3.0, 'abc')", "abc", "CHAR(3) NOT NULL");
+
+ f12.checkNull("nvl2('ab', CAST(NULL AS VARCHAR(6)), 'def')");
+ f12.checkNull("nvl2(NULL, 'abc', NULL)");
+ f12.checkNull("nvl2(NULL, NULL, NULL)");
Review Comment:
@mihaibudiu Hello, sorry for replying so late. I found a problem.
NVL2 (2.0, 'abc', true) is allowed in type verification on calcite. The string type and the Boolean type are comparable. I am not sure about this. According to my understanding, it is not allowed. This is also not allowed in spark.
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "julianhyde (via GitHub)" <gi...@apache.org>.
julianhyde commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1597163878
##########
site/_docs/reference.md:
##########
@@ -2812,6 +2812,7 @@ In the following:
| b m p s | MD5(string) | Calculates an MD5 128-bit checksum of *string* and returns it as a hex string
| m | MONTHNAME(date) | Returns the name, in the connection's locale, of the month in *datetime*; for example, it returns '二月' for both DATE '2020-02-10' and TIMESTAMP '2020-02-10 10:10:10'
| o s | NVL(value1, value2) | Returns *value1* if *value1* is not null, otherwise *value2*
+| s | NVL2(value1, value2, value3) | Returns *value2* if *value1* is not null, or *value3* otherwise.
Review Comment:
remove trailing '.'
Oracle and Spark
Why ', or value3 otherwise' and not ', otherwise value3' when line above says 'otherwise value2'?
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1589846526
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -270,6 +270,14 @@ private static SqlCall transformConvert(SqlValidator validator, SqlCall call) {
.andThen(SqlTypeTransforms.TO_NULLABLE_ALL),
OperandTypes.SAME_SAME);
+ /** The "NVL2(value, value, value)" function. */
+ @LibraryOperator(libraries = {SPARK})
Review Comment:
I borrowed from NVL, it seems like NVL2 doesn't necessarily have to keep the types the same
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3785:
URL: https://github.com/apache/calcite/pull/3785#issuecomment-2093057284
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3785) **Quality Gate passed**
Issues
 [23 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3785&resolved=false&inNewCodePeriod=true)
 [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3785&metric=new_accepted_issues&view=list)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3785&resolved=false&inNewCodePeriod=true)
 [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3785&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3785&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3785)
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "julianhyde (via GitHub)" <gi...@apache.org>.
julianhyde commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1597166998
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -10036,6 +10036,34 @@ void assertSubFunReturns(boolean binary, String s, int start,
checkNvl(f, FunctionAlias.of(SqlLibraryOperators.NVL));
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6397">[CALCITE-6397]
+ * Add NVL2 function (enabled in Spark library). </a>.
+ */
+ @Test void testNvl2Func() {
+ final SqlOperatorFixture f = fixture();
+ f.setFor(SqlLibraryOperators.NVL2, VmName.EXPAND);
+ f.checkFails("^nvl2(NULL, 2, 1)^",
+ "No match found for function signature "
+ + "NVL2\\(<NULL>, <NUMERIC>, <NUMERIC>\\)", false);
+
+ final SqlOperatorFixture f12 = f
Review Comment:
need cases like one argument is `DECIMAL(3, 1)` and another is `DECIMAL(4, 3)`
you only seem to be testing the easy cases e.g. two `CHAR(2)`, two `CHAR(3)`. The users won't test the easy 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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "julianhyde (via GitHub)" <gi...@apache.org>.
julianhyde commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1597162522
##########
core/src/main/java/org/apache/calcite/sql/type/ReturnTypes.java:
##########
@@ -551,6 +551,13 @@ public static SqlCall stripSeparator(SqlCall call) {
opBinding -> opBinding.getTypeFactory().leastRestrictive(
opBinding.collectOperandTypes());
+ public static final SqlReturnTypeInference NVL2_RESTRICTIVE = opBinding -> {
+ RelDataType opType1 = opBinding.getOperandType(1);
+ RelDataType opType2 = opBinding.getOperandType(2);
+ return opBinding.getOperandType(0).getSqlTypeName() == SqlTypeName.NULL ? opType2 : opType1;
+ };
+
+
Review Comment:
remove blank line
--
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-6397] Add NVL2 function (enabled in Oracle, Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1603471671
##########
core/src/main/java/org/apache/calcite/sql/type/ReturnTypes.java:
##########
@@ -551,6 +551,13 @@ public static SqlCall stripSeparator(SqlCall call) {
opBinding -> opBinding.getTypeFactory().leastRestrictive(
opBinding.collectOperandTypes());
+ public static final SqlReturnTypeInference NVL2_RESTRICTIVE = opBinding -> {
Review Comment:
@mihaibudiu You mean I need to uniformly convert to biggesttype?
I just found out that you are still on vacation. You don’t need to review so quickly. Have a happy vacation.
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1591363888
##########
core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java:
##########
@@ -986,6 +986,14 @@ public static SqlSingleOperandTypeChecker same(int operandCount,
public static final SqlSingleOperandTypeChecker ANY_ANY =
family(SqlTypeFamily.ANY, SqlTypeFamily.ANY);
+
+ public static final SqlSingleOperandTypeChecker SECOND_THIRD_SAME =
+ new SameOperandTypeChecker(3) {
Review Comment:
If you happened to see https://issues.apache.org/jira/browse/CALCITE-6383 you may have noticed that the SameOperatndTypeChecker does not enforce that the operands have the same type, but only that they are comparable. Perhaps if this is what you want you should document this fact here.
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -10036,6 +10036,34 @@ void assertSubFunReturns(boolean binary, String s, int start,
checkNvl(f, FunctionAlias.of(SqlLibraryOperators.NVL));
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6397">[CALCITE-6397]
+ * Add NVL2 function (enabled in Spark library). </a>.
+ */
+ @Test void testNvl2Func() {
+ final SqlOperatorFixture f = fixture();
+ f.setFor(SqlLibraryOperators.NVL2, VmName.EXPAND);
+ f.checkFails("^nvl2(NULL, 2, 1)^",
+ "No match found for function signature "
+ + "NVL2\\(<NULL>, <NUMERIC>, <NUMERIC>\\)", false);
+
+ final SqlOperatorFixture f12 = f
Review Comment:
the SameOperandTypeChecker allows different types for the operands 1 & 2, including numeric and string. Perhaps you should have some tests for these 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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1596944009
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -10036,6 +10036,45 @@ void assertSubFunReturns(boolean binary, String s, int start,
checkNvl(f, FunctionAlias.of(SqlLibraryOperators.NVL));
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6397">[CALCITE-6397]
+ * Add NVL2 function (enabled in Spark library). </a>.
+ */
+ @Test void testNvl2Func() {
+ final SqlOperatorFixture f = fixture();
+ f.setFor(SqlLibraryOperators.NVL2, VmName.EXPAND);
+ f.checkFails("^nvl2(NULL, 2, 1)^",
+ "No match found for function signature "
+ + "NVL2\\(<NULL>, <NUMERIC>, <NUMERIC>\\)", false);
+
+ final SqlOperatorFixture f12 = f
+ .withLibrary(SqlLibrary.SPARK);
+ f12.checkScalar("nvl2(NULL, 2, 1)", "1", "INTEGER NOT NULL");
+ f12.checkScalar("nvl2(true, true, false)", true, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(false, true, false)", true, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(NULL, true, false)", false, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(3, 2, 1)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("nvl2(3, 'a', 'b')", "a", "CHAR(1) NOT NULL");
+ f12.checkScalar("nvl2(NULL, 'a', 'b')", "b", "CHAR(1) NOT NULL");
+ f12.checkScalar("nvl2(NULL, 'ab', 'de')", "de", "CHAR(2) NOT NULL");
+ f12.checkScalar("nvl2('ab', 'abc', 'def')", "abc", "CHAR(3) NOT NULL");
+ f12.checkScalar("nvl2('a', 3, 2)", "3", "INTEGER NOT NULL");
+
+ // check operand 1 and operand 2 are inconsistent
+ f12.checkScalar("NVL2(2.0, 'abc', 2)", "abc", "CHAR(3) NOT NULL");
+ f12.checkScalar("NVL2(NULL, 'abc', 2)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("NVL2(NULL, 3.0, 4.0)", "4.0", "DECIMAL(2, 1) NOT NULL");
+ f12.checkScalar("NVL2(NULL, 'abc', 2)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("NVL2('abc', 3.0, 4.0)", "3.0", "DECIMAL(2, 1) NOT NULL");
+ f12.checkScalar("NVL2(1, 3.0, 'abc')", "3.0", "DECIMAL(2, 1) NOT NULL");
+ f12.checkScalar("NVL2(NULL, 3.0, 'abc')", "abc", "CHAR(3) NOT NULL");
+
+ f12.checkNull("nvl2('ab', CAST(NULL AS VARCHAR(6)), 'def')");
+ f12.checkNull("nvl2(NULL, 'abc', NULL)");
+ f12.checkNull("nvl2(NULL, NULL, NULL)");
Review Comment:
done
--
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-6397] Add NVL2 function (enabled in Oracle, Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on PR #3785:
URL: https://github.com/apache/calcite/pull/3785#issuecomment-2110531888
@mihaibudiu PATL
--
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-6397] Add NVL2 function (enabled in Oracle, Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1603471671
##########
core/src/main/java/org/apache/calcite/sql/type/ReturnTypes.java:
##########
@@ -551,6 +551,13 @@ public static SqlCall stripSeparator(SqlCall call) {
opBinding -> opBinding.getTypeFactory().leastRestrictive(
opBinding.collectOperandTypes());
+ public static final SqlReturnTypeInference NVL2_RESTRICTIVE = opBinding -> {
Review Comment:
@mihaibudiu You mean I need to uniformly convert to biggesttype?
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "julianhyde (via GitHub)" <gi...@apache.org>.
julianhyde commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1597157484
##########
core/src/main/java/org/apache/calcite/sql/type/ReturnTypes.java:
##########
@@ -551,6 +551,13 @@ public static SqlCall stripSeparator(SqlCall call) {
opBinding -> opBinding.getTypeFactory().leastRestrictive(
opBinding.collectOperandTypes());
+ public static final SqlReturnTypeInference NVL2_RESTRICTIVE = opBinding -> {
Review Comment:
NEed javadoc
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1596920047
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -10036,6 +10036,45 @@ void assertSubFunReturns(boolean binary, String s, int start,
checkNvl(f, FunctionAlias.of(SqlLibraryOperators.NVL));
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6397">[CALCITE-6397]
+ * Add NVL2 function (enabled in Spark library). </a>.
+ */
+ @Test void testNvl2Func() {
+ final SqlOperatorFixture f = fixture();
+ f.setFor(SqlLibraryOperators.NVL2, VmName.EXPAND);
+ f.checkFails("^nvl2(NULL, 2, 1)^",
+ "No match found for function signature "
+ + "NVL2\\(<NULL>, <NUMERIC>, <NUMERIC>\\)", false);
+
+ final SqlOperatorFixture f12 = f
+ .withLibrary(SqlLibrary.SPARK);
+ f12.checkScalar("nvl2(NULL, 2, 1)", "1", "INTEGER NOT NULL");
+ f12.checkScalar("nvl2(true, true, false)", true, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(false, true, false)", true, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(NULL, true, false)", false, "BOOLEAN NOT NULL");
+ f12.checkScalar("nvl2(3, 2, 1)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("nvl2(3, 'a', 'b')", "a", "CHAR(1) NOT NULL");
+ f12.checkScalar("nvl2(NULL, 'a', 'b')", "b", "CHAR(1) NOT NULL");
+ f12.checkScalar("nvl2(NULL, 'ab', 'de')", "de", "CHAR(2) NOT NULL");
+ f12.checkScalar("nvl2('ab', 'abc', 'def')", "abc", "CHAR(3) NOT NULL");
+ f12.checkScalar("nvl2('a', 3, 2)", "3", "INTEGER NOT NULL");
+
+ // check operand 1 and operand 2 are inconsistent
+ f12.checkScalar("NVL2(2.0, 'abc', 2)", "abc", "CHAR(3) NOT NULL");
+ f12.checkScalar("NVL2(NULL, 'abc', 2)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("NVL2(NULL, 3.0, 4.0)", "4.0", "DECIMAL(2, 1) NOT NULL");
+ f12.checkScalar("NVL2(NULL, 'abc', 2)", "2", "INTEGER NOT NULL");
+ f12.checkScalar("NVL2('abc', 3.0, 4.0)", "3.0", "DECIMAL(2, 1) NOT NULL");
+ f12.checkScalar("NVL2(1, 3.0, 'abc')", "3.0", "DECIMAL(2, 1) NOT NULL");
+ f12.checkScalar("NVL2(NULL, 3.0, 'abc')", "abc", "CHAR(3) NOT NULL");
+
+ f12.checkNull("nvl2('ab', CAST(NULL AS VARCHAR(6)), 'def')");
+ f12.checkNull("nvl2(NULL, 'abc', NULL)");
+ f12.checkNull("nvl2(NULL, NULL, NULL)");
Review Comment:
@mihaibudiu Hello, sorry for replying so late. I found a problem.
NVL2 (2.0, 'abc', true) is allowed in type verification. The string type and the Boolean type are comparable. I am not sure about this. According to my understanding, it is not allowed. This is also not allowed in spark.
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "julianhyde (via GitHub)" <gi...@apache.org>.
julianhyde commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1597161501
##########
core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java:
##########
@@ -418,6 +419,32 @@ private static RexNode convertNvl(SqlRexContext cx, SqlCall call) {
operand1)));
}
+ /** Converts a call to the {@code NVL2} function. */
+ private static RexNode convertNvl2(SqlRexContext cx, SqlCall call) {
+ final RexBuilder rexBuilder = cx.getRexBuilder();
+ final RexNode operand0 =
+ cx.convertExpression(call.getOperandList().get(0));
+ final RexNode operand1 =
+ cx.convertExpression(call.getOperandList().get(1));
+ final RexNode operand2 =
+ cx.convertExpression(call.getOperandList().get(2));
+ final RelDataType type =
+ cx.getValidator().getValidatedNodeType(call);
+ // Preserve Operand Nullability
Review Comment:
Why preserve operand nullability? Result is nullable iff either operand 1 or 2 is nullable.
A comment that you translate NVL2(x, y, z) to CASE WHEN x is NULL THEN y ELSE z END would make this method much easier to understand.
Why convert operands one at a time? Use `convertOperands`.
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "julianhyde (via GitHub)" <gi...@apache.org>.
julianhyde commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1597162056
##########
core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java:
##########
@@ -418,6 +419,32 @@ private static RexNode convertNvl(SqlRexContext cx, SqlCall call) {
operand1)));
}
+ /** Converts a call to the {@code NVL2} function. */
+ private static RexNode convertNvl2(SqlRexContext cx, SqlCall call) {
+ final RexBuilder rexBuilder = cx.getRexBuilder();
+ final RexNode operand0 =
+ cx.convertExpression(call.getOperandList().get(0));
+ final RexNode operand1 =
+ cx.convertExpression(call.getOperandList().get(1));
+ final RexNode operand2 =
+ cx.convertExpression(call.getOperandList().get(2));
+ final RelDataType type =
+ cx.getValidator().getValidatedNodeType(call);
+ // Preserve Operand Nullability
Review Comment:
This method could probably be 6 lines long.
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3785:
URL: https://github.com/apache/calcite/pull/3785#issuecomment-2104898121
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3785) **Quality Gate passed**
Issues
 [1 New issue](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3785&resolved=false&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3785&metric=new_accepted_issues&view=list)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3785&resolved=false&sinceLeakPeriod=true)
 [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3785&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3785&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3785)
--
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-6397] Add NVL2 function (enabled in Oracle, Spark library) [calcite]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3785:
URL: https://github.com/apache/calcite/pull/3785#issuecomment-2108615228
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3785) **Quality Gate passed**
Issues
 [1 New issue](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3785&resolved=false&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3785&metric=new_accepted_issues&view=list)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3785&resolved=false&sinceLeakPeriod=true)
 [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3785&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3785&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3785)
--
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-6397] Add NVL2 function (enabled in Oracle, Spark library) [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu merged PR #3785:
URL: https://github.com/apache/calcite/pull/3785
--
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-6397] Add NVL2 function (enabled in Oracle, Spark library) [calcite]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3785:
URL: https://github.com/apache/calcite/pull/3785#issuecomment-2137464549
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3785) **Quality Gate passed**
Issues
 [3 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3785&resolved=false&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3785&resolutions=WONTFIX)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3785&resolved=false&sinceLeakPeriod=true)
 [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3785&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3785&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3785)
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1592622036
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -10036,6 +10036,34 @@ void assertSubFunReturns(boolean binary, String s, int start,
checkNvl(f, FunctionAlias.of(SqlLibraryOperators.NVL));
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6397">[CALCITE-6397]
+ * Add NVL2 function (enabled in Spark library). </a>.
+ */
+ @Test void testNvl2Func() {
+ final SqlOperatorFixture f = fixture();
+ f.setFor(SqlLibraryOperators.NVL2, VmName.EXPAND);
+ f.checkFails("^nvl2(NULL, 2, 1)^",
+ "No match found for function signature "
+ + "NVL2\\(<NULL>, <NUMERIC>, <NUMERIC>\\)", false);
+
+ final SqlOperatorFixture f12 = f
Review Comment:
done
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1589499335
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -270,6 +270,14 @@ private static SqlCall transformConvert(SqlValidator validator, SqlCall call) {
.andThen(SqlTypeTransforms.TO_NULLABLE_ALL),
OperandTypes.SAME_SAME);
+ /** The "NVL2(value, value, value)" function. */
+ @LibraryOperator(libraries = {SPARK})
Review Comment:
why does the first operand have to have the same type as the other two?
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1597579339
##########
site/_docs/reference.md:
##########
@@ -2812,6 +2812,7 @@ In the following:
| b m p s | MD5(string) | Calculates an MD5 128-bit checksum of *string* and returns it as a hex string
| m | MONTHNAME(date) | Returns the name, in the connection's locale, of the month in *datetime*; for example, it returns '二月' for both DATE '2020-02-10' and TIMESTAMP '2020-02-10 10:10:10'
| o s | NVL(value1, value2) | Returns *value1* if *value1* is not null, otherwise *value2*
+| s | NVL2(value1, value2, value3) | Returns *value2* if *value1* is not null, or *value3* otherwise.
Review Comment:
fix
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -10397,6 +10397,50 @@ void assertSubFunReturns(boolean binary, String s, int start,
checkNvl(f, FunctionAlias.of(SqlLibraryOperators.NVL));
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6397">[CALCITE-6397]
+ * Add NVL2 function (enabled in Spark library). </a>.
Review Comment:
done
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on PR #3785:
URL: https://github.com/apache/calcite/pull/3785#issuecomment-2104872020
@mihaibudiu I would like to ask a question. The type check of NVL2 (2.0, 'abc', true) in calcite is allowed. The string type and the boolean type are comparable. I am not sure about this. According to my understanding, this is is not allowed
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "julianhyde (via GitHub)" <gi...@apache.org>.
julianhyde commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1597164314
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -10397,6 +10397,50 @@ void assertSubFunReturns(boolean binary, String s, int start,
checkNvl(f, FunctionAlias.of(SqlLibraryOperators.NVL));
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6397">[CALCITE-6397]
+ * Add NVL2 function (enabled in Spark library). </a>.
Review Comment:
remove '. '.
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "julianhyde (via GitHub)" <gi...@apache.org>.
julianhyde commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1597156525
##########
core/src/main/java/org/apache/calcite/sql/SqlKind.java:
##########
@@ -421,9 +421,12 @@ public enum SqlKind {
/** {@code DECODE} function (Oracle). */
DECODE,
- /** {@code NVL} function (Oracle). */
+ /** {@code NVL} function (Oracle, Spark). */
NVL,
+ /** {@code NVL2} function (Oracle). */
Review Comment:
Are you saying that NVL2 doesn't exist on Spark?
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1597579090
##########
core/src/main/java/org/apache/calcite/sql/SqlKind.java:
##########
@@ -421,9 +421,12 @@ public enum SqlKind {
/** {@code DECODE} function (Oracle). */
DECODE,
- /** {@code NVL} function (Oracle). */
+ /** {@code NVL} function (Oracle, Spark). */
NVL,
+ /** {@code NVL2} function (Oracle). */
Review Comment:
Sorry, I forgot to add
--
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-6397] Add NVL2 function (enabled in Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1597624347
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -10036,6 +10036,34 @@ void assertSubFunReturns(boolean binary, String s, int start,
checkNvl(f, FunctionAlias.of(SqlLibraryOperators.NVL));
}
+ /** Test case for
+ * <a href="https://issues.apache.org/jira/browse/CALCITE-6397">[CALCITE-6397]
+ * Add NVL2 function (enabled in Spark library). </a>.
+ */
+ @Test void testNvl2Func() {
+ final SqlOperatorFixture f = fixture();
+ f.setFor(SqlLibraryOperators.NVL2, VmName.EXPAND);
+ f.checkFails("^nvl2(NULL, 2, 1)^",
+ "No match found for function signature "
+ + "NVL2\\(<NULL>, <NUMERIC>, <NUMERIC>\\)", false);
+
+ final SqlOperatorFixture f12 = f
Review Comment:
ok, done
--
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-6397] Add NVL2 function (enabled in Oracle, Spark library) [calcite]
Posted by "caicancai (via GitHub)" <gi...@apache.org>.
caicancai commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1603529235
##########
core/src/main/java/org/apache/calcite/sql/type/ReturnTypes.java:
##########
@@ -551,6 +551,13 @@ public static SqlCall stripSeparator(SqlCall call) {
opBinding -> opBinding.getTypeFactory().leastRestrictive(
opBinding.collectOperandTypes());
+ public static final SqlReturnTypeInference NVL2_RESTRICTIVE = opBinding -> {
Review Comment:
done
--
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-6397] Add NVL2 function (enabled in Oracle, Spark library) [calcite]
Posted by "YiwenWu (via GitHub)" <gi...@apache.org>.
YiwenWu commented on code in PR #3785:
URL: https://github.com/apache/calcite/pull/3785#discussion_r1618723448
##########
core/src/main/java/org/apache/calcite/sql/SqlKind.java:
##########
@@ -421,9 +421,12 @@ public enum SqlKind {
/** {@code DECODE} function (Oracle). */
DECODE,
- /** {@code NVL} function (Oracle). */
+ /** {@code NVL} function (Oracle, Spark). */
NVL,
+ /** {@code NVL2} function (Oracle). */
Review Comment:
+1, comments are not updated
--
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