You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "zoudan (via GitHub)" <gi...@apache.org> on 2023/05/19 10:00:59 UTC
[GitHub] [calcite] zoudan opened a new pull request, #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
zoudan opened a new pull request, #3214:
URL: https://github.com/apache/calcite/pull/3214
(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
[GitHub] [calcite] sonarcloud[bot] commented on pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3214:
URL: https://github.com/apache/calcite/pull/3214#issuecomment-1563741869
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3214)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3214&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3214&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3214&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=CODE_SMELL) [7 Code Smells](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_coverage&view=list) [95.3% Coverage](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_duplicated_lines_density&view=list)
--
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
[GitHub] [calcite] rubenada commented on pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on PR #3214:
URL: https://github.com/apache/calcite/pull/3214#issuecomment-1563944729
Thanks @tanclary !
@zoudan could you please squash commits into a single one? I'll proceed with the merge afterwards.
--
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
[GitHub] [calcite] sonarcloud[bot] commented on pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3214:
URL: https://github.com/apache/calcite/pull/3214#issuecomment-1563982067
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3214)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3214&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3214&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3214&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=CODE_SMELL) [7 Code Smells](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_coverage&view=list) [95.3% Coverage](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_duplicated_lines_density&view=list)
--
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
[GitHub] [calcite] sonarcloud[bot] commented on pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3214:
URL: https://github.com/apache/calcite/pull/3214#issuecomment-1560389123
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3214)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3214&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3214&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3214&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=CODE_SMELL) [7 Code Smells](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_coverage&view=list) [94.3% Coverage](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_duplicated_lines_density&view=list)
--
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
[GitHub] [calcite] sonarcloud[bot] commented on pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3214:
URL: https://github.com/apache/calcite/pull/3214#issuecomment-1554357482
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3214)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3214&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3214&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3214&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=CODE_SMELL) [2 Code Smells](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_coverage&view=list) [92.1% Coverage](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_duplicated_lines_density&view=list)
--
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
[GitHub] [calcite] rubenada commented on a diff in pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on code in PR #3214:
URL: https://github.com/apache/calcite/pull/3214#discussion_r1203671206
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5539,6 +5539,72 @@ private static void checkIf(SqlOperatorFixture f) {
f.checkNull("atan2(1, cast(null as double))");
}
+ @Test void testAcoshFunc() {
+ final SqlOperatorFixture f0 = fixture().setFor(SqlLibraryOperators.ACOSH);
+ f0.checkFails("^acosh(1)^",
+ "No match found for function signature ACOSH\\(<NUMERIC>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkType("acosh(1)", "DOUBLE NOT NULL");
+ f.checkType("acosh(cast(1 as Decimal))", "DOUBLE NOT NULL");
+ f.checkType("acosh(case when false then 1 else null end)", "DOUBLE");
+ f.checkType("acosh('abc')", "DOUBLE NOT NULL");
+ f.checkScalarApprox("acosh(1)", "DOUBLE NOT NULL",
+ isWithin(0d, 0.0001d));
+ f.checkScalarApprox("acosh(cast(10 as decimal))", "DOUBLE NOT NULL",
+ isWithin(2.9932d, 0.0001d));
+ f.checkNull("acosh(cast(null as integer))");
+ f.checkNull("acosh(cast(null as double))");
+ f.checkFails("acosh(0.1)",
+ "Input parameter of acosh cannot be small than 1!",
Review Comment:
How is this test passing? Shouldn't the expected error message be adapted?
--
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
[GitHub] [calcite] rubenada commented on a diff in pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on code in PR #3214:
URL: https://github.com/apache/calcite/pull/3214#discussion_r1202422359
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -1854,6 +1854,21 @@ public static double acos(double b0) {
return Math.acos(b0);
}
+ // ACOSH
+ /** SQL <code>ACOSH</code> operator applied to BigDecimal values. */
+ public static double acosh(BigDecimal b0) {
+ return acosh(b0.doubleValue());
+ }
+
+ /** SQL <code>ACOSH</code> operator applied to double values. */
+ public static double acosh(double b0) {
+ if (b0 < 1) {
+ SQLException e = new SQLException("Input parameter of acosh cannot be small than 1!");
Review Comment:
I would lean towards throwing an IllegalArgumentException in this case (same applies to the `atanh` method).
Also, I think it would be more correct to use as message "... cannot be less than 1".
--
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
[GitHub] [calcite] zoudan commented on a diff in pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "zoudan (via GitHub)" <gi...@apache.org>.
zoudan commented on code in PR #3214:
URL: https://github.com/apache/calcite/pull/3214#discussion_r1202480641
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -1854,6 +1854,21 @@ public static double acos(double b0) {
return Math.acos(b0);
}
+ // ACOSH
+ /** SQL <code>ACOSH</code> operator applied to BigDecimal values. */
+ public static double acosh(BigDecimal b0) {
+ return acosh(b0.doubleValue());
+ }
+
+ /** SQL <code>ACOSH</code> operator applied to double values. */
+ public static double acosh(double b0) {
+ if (b0 < 1) {
+ SQLException e = new SQLException("Input parameter of acosh cannot be small than 1!");
Review Comment:
Thanks, I will update it soon
--
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
[GitHub] [calcite] zoudan commented on a diff in pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "zoudan (via GitHub)" <gi...@apache.org>.
zoudan commented on code in PR #3214:
URL: https://github.com/apache/calcite/pull/3214#discussion_r1203720887
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5539,6 +5539,72 @@ private static void checkIf(SqlOperatorFixture f) {
f.checkNull("atan2(1, cast(null as double))");
}
+ @Test void testAcoshFunc() {
+ final SqlOperatorFixture f0 = fixture().setFor(SqlLibraryOperators.ACOSH);
+ f0.checkFails("^acosh(1)^",
+ "No match found for function signature ACOSH\\(<NUMERIC>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkType("acosh(1)", "DOUBLE NOT NULL");
+ f.checkType("acosh(cast(1 as Decimal))", "DOUBLE NOT NULL");
+ f.checkType("acosh(case when false then 1 else null end)", "DOUBLE");
+ f.checkType("acosh('abc')", "DOUBLE NOT NULL");
+ f.checkScalarApprox("acosh(1)", "DOUBLE NOT NULL",
+ isWithin(0d, 0.0001d));
+ f.checkScalarApprox("acosh(cast(10 as decimal))", "DOUBLE NOT NULL",
+ isWithin(2.9932d, 0.0001d));
+ f.checkNull("acosh(cast(null as integer))");
+ f.checkNull("acosh(cast(null as double))");
+ f.checkFails("acosh(0.1)",
+ "Input parameter of acosh cannot be small than 1!",
Review Comment:
I found it is because we only check this expression will be successful during parse and validate. The error message has been ignored, you could see more details in https://github.com/apache/calcite/blob/f32289870be80e69dabc5b7e24bd6c777d4eb688/testkit/src/main/java/org/apache/calcite/test/SqlOperatorFixtureImpl.java#L161
Maybe we should improve 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
[GitHub] [calcite] tanclary commented on a diff in pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "tanclary (via GitHub)" <gi...@apache.org>.
tanclary commented on code in PR #3214:
URL: https://github.com/apache/calcite/pull/3214#discussion_r1205820685
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -1897,6 +1930,29 @@ public static double atan2(double b0, double b1) {
return Math.atan2(b0, b1);
}
+ // ATANH
+ /** SQL <code>ATANH</code> operator applied to BigDecimal values. */
+ public static double atanh(BigDecimal b) {
+ return atanh(b.doubleValue());
+ }
+
+ /** SQL <code>ATANH</code> operator applied to double values. */
+ public static double atanh(double b) {
Review Comment:
nit: could just check abs(b) <= 1
--
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
[GitHub] [calcite] rubenada commented on pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on PR #3214:
URL: https://github.com/apache/calcite/pull/3214#issuecomment-1560838837
LGTM
--
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
[GitHub] [calcite] rubenada commented on a diff in pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on code in PR #3214:
URL: https://github.com/apache/calcite/pull/3214#discussion_r1202515931
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -1854,6 +1854,20 @@ public static double acos(double b0) {
return Math.acos(b0);
}
+ // ACOSH
+ /** SQL <code>ACOSH</code> operator applied to BigDecimal values. */
+ public static double acosh(BigDecimal b0) {
+ return acosh(b0.doubleValue());
+ }
+
+ /** SQL <code>ACOSH</code> operator applied to double values. */
+ public static double acosh(double b0) {
+ if (b0 < 1) {
+ throw new IllegalArgumentException("Input parameter of acosh cannot be less than 1!");
+ }
+ return Math.log(Math.sqrt(b0 * b0 - 1.0) + b0);
Review Comment:
For the newbies on trigonometric functions :) , is there any link you can provide to show where these formulas come from?
--
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
[GitHub] [calcite] zoudan commented on a diff in pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "zoudan (via GitHub)" <gi...@apache.org>.
zoudan commented on code in PR #3214:
URL: https://github.com/apache/calcite/pull/3214#discussion_r1203314154
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -1854,6 +1854,20 @@ public static double acos(double b0) {
return Math.acos(b0);
}
+ // ACOSH
+ /** SQL <code>ACOSH</code> operator applied to BigDecimal values. */
+ public static double acosh(BigDecimal b0) {
+ return acosh(b0.doubleValue());
+ }
+
+ /** SQL <code>ACOSH</code> operator applied to double values. */
+ public static double acosh(double b0) {
+ if (b0 < 1) {
+ throw new IllegalArgumentException("Input parameter of acosh cannot be less than 1!");
+ }
+ return Math.log(Math.sqrt(b0 * b0 - 1.0) + b0);
Review Comment:
https://en.wikipedia.org/wiki/Inverse_hyperbolic_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
[GitHub] [calcite] rubenada commented on a diff in pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on code in PR #3214:
URL: https://github.com/apache/calcite/pull/3214#discussion_r1203672908
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5539,6 +5539,72 @@ private static void checkIf(SqlOperatorFixture f) {
f.checkNull("atan2(1, cast(null as double))");
}
+ @Test void testAcoshFunc() {
+ final SqlOperatorFixture f0 = fixture().setFor(SqlLibraryOperators.ACOSH);
+ f0.checkFails("^acosh(1)^",
+ "No match found for function signature ACOSH\\(<NUMERIC>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkType("acosh(1)", "DOUBLE NOT NULL");
+ f.checkType("acosh(cast(1 as Decimal))", "DOUBLE NOT NULL");
+ f.checkType("acosh(case when false then 1 else null end)", "DOUBLE");
+ f.checkType("acosh('abc')", "DOUBLE NOT NULL");
+ f.checkScalarApprox("acosh(1)", "DOUBLE NOT NULL",
+ isWithin(0d, 0.0001d));
+ f.checkScalarApprox("acosh(cast(10 as decimal))", "DOUBLE NOT NULL",
+ isWithin(2.9932d, 0.0001d));
+ f.checkNull("acosh(cast(null as integer))");
+ f.checkNull("acosh(cast(null as double))");
+ f.checkFails("acosh(0.1)",
+ "Input parameter of acosh cannot be small than 1!",
+ true);
+ };
+ f0.forEachLibrary(list(SqlLibrary.ALL), consumer);
+ }
+
+ @Test void testAsinhFunc() {
+ final SqlOperatorFixture f0 = fixture().setFor(SqlLibraryOperators.ASINH);
+ f0.checkFails("^asinh(1)^",
+ "No match found for function signature ASINH\\(<NUMERIC>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkType("asinh(1)", "DOUBLE NOT NULL");
+ f.checkType("asinh(cast(1 as Decimal))", "DOUBLE NOT NULL");
+ f.checkType("asinh(case when false then 1 else null end)", "DOUBLE");
+ f.checkType("asinh('abc')", "DOUBLE NOT NULL");
+ f.checkScalarApprox("asinh(-2.5)", "DOUBLE NOT NULL",
+ isWithin(-1.6472d, 0.0001d));
+ f.checkScalarApprox("asinh(cast(10 as decimal))", "DOUBLE NOT NULL",
+ isWithin(2.9982, 0.0001d));
+ f.checkNull("asinh(cast(null as integer))");
+ f.checkNull("asinh(cast(null as double))");
+ };
+ f0.forEachLibrary(list(SqlLibrary.ALL), consumer);
+ }
+
+ @Test void testAtanhFunc() {
+ final SqlOperatorFixture f0 = fixture().setFor(SqlLibraryOperators.ATANH);
+ f0.checkFails("^atanh(1)^",
+ "No match found for function signature ATANH\\(<NUMERIC>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkType("atanh(0.1)", "DOUBLE NOT NULL");
+ f.checkType("atanh(cast(0 as Decimal))", "DOUBLE NOT NULL");
+ f.checkType("atanh(case when false then 0 else null end)", "DOUBLE");
+ f.checkType("atanh('abc')", "DOUBLE NOT NULL");
+ f.checkScalarApprox("atanh(0.76159416)", "DOUBLE NOT NULL",
+ isWithin(1d, 0.0001d));
+ f.checkScalarApprox("atanh(cast(-0.1 as decimal))", "DOUBLE NOT NULL",
+ isWithin(-0.1003d, 0.0001d));
+ f.checkNull("atanh(cast(null as integer))");
+ f.checkNull("atanh(cast(null as double))");
+ f.checkFails("atanh(10)",
Review Comment:
Could you please add tests for the cases 1 and -1? (which should fail according to the links I provided on the separate 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
[GitHub] [calcite] rubenada commented on a diff in pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on code in PR #3214:
URL: https://github.com/apache/calcite/pull/3214#discussion_r1203727760
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -5539,6 +5539,72 @@ private static void checkIf(SqlOperatorFixture f) {
f.checkNull("atan2(1, cast(null as double))");
}
+ @Test void testAcoshFunc() {
+ final SqlOperatorFixture f0 = fixture().setFor(SqlLibraryOperators.ACOSH);
+ f0.checkFails("^acosh(1)^",
+ "No match found for function signature ACOSH\\(<NUMERIC>\\)",
+ false);
+ final Consumer<SqlOperatorFixture> consumer = f -> {
+ f.checkType("acosh(1)", "DOUBLE NOT NULL");
+ f.checkType("acosh(cast(1 as Decimal))", "DOUBLE NOT NULL");
+ f.checkType("acosh(case when false then 1 else null end)", "DOUBLE");
+ f.checkType("acosh('abc')", "DOUBLE NOT NULL");
+ f.checkScalarApprox("acosh(1)", "DOUBLE NOT NULL",
+ isWithin(0d, 0.0001d));
+ f.checkScalarApprox("acosh(cast(10 as decimal))", "DOUBLE NOT NULL",
+ isWithin(2.9932d, 0.0001d));
+ f.checkNull("acosh(cast(null as integer))");
+ f.checkNull("acosh(cast(null as double))");
+ f.checkFails("acosh(0.1)",
+ "Input parameter of acosh cannot be small than 1!",
Review Comment:
Ah, ok. Thanks for the info. It is certainly counter-intuitive and probably there's room for improvement, but IMO this is out of the scope of the current PR.
I would say, please just align this "expected error message" with the actual error that is thrown, just for the sake of correctness (and in case the fixture mechanism gets improved in the future).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [calcite] sonarcloud[bot] commented on pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3214:
URL: https://github.com/apache/calcite/pull/3214#issuecomment-1559654228
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3214)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3214&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3214&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3214&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=CODE_SMELL) [4 Code Smells](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_coverage&view=list) [94.3% Coverage](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_duplicated_lines_density&view=list)
--
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
[GitHub] [calcite] sonarcloud[bot] commented on pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3214:
URL: https://github.com/apache/calcite/pull/3214#issuecomment-1560778843
Kudos, SonarCloud Quality Gate passed! [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3214)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=BUG) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=BUG)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=VULNERABILITY) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=VULNERABILITY)
[](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3214&resolved=false&types=SECURITY_HOTSPOT) [](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3214&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3214&resolved=false&types=SECURITY_HOTSPOT)
[](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=CODE_SMELL) [](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=CODE_SMELL) [7 Code Smells](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3214&resolved=false&types=CODE_SMELL)
[](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_coverage&view=list) [94.3% Coverage](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_coverage&view=list)
[](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_duplicated_lines_density&view=list) [0.0% Duplication](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3214&metric=new_duplicated_lines_density&view=list)
--
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
[GitHub] [calcite] rubenada commented on a diff in pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on code in PR #3214:
URL: https://github.com/apache/calcite/pull/3214#discussion_r1202422359
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -1854,6 +1854,21 @@ public static double acos(double b0) {
return Math.acos(b0);
}
+ // ACOSH
+ /** SQL <code>ACOSH</code> operator applied to BigDecimal values. */
+ public static double acosh(BigDecimal b0) {
+ return acosh(b0.doubleValue());
+ }
+
+ /** SQL <code>ACOSH</code> operator applied to double values. */
+ public static double acosh(double b0) {
+ if (b0 < 1) {
+ SQLException e = new SQLException("Input parameter of acosh cannot be small than 1!");
Review Comment:
I would lean towards throwing an IllegalArgumentException in this case (same applies to the `atanh`method).
Also, I think it would me more correct if the message says "... cannot be less than 1".
--
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
[GitHub] [calcite] rubenada commented on a diff in pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on code in PR #3214:
URL: https://github.com/apache/calcite/pull/3214#discussion_r1202508174
##########
core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java:
##########
@@ -1263,6 +1263,32 @@ private static RelDataType arrayReturnType(SqlOperatorBinding opBinding) {
OperandTypes.NUMERIC,
SqlFunctionCategory.NUMERIC);
+ /** The {@code ACOSH(numeric)} function; returns the inverse hyperbolic cosine
+ * of {@code value}. */
+ @LibraryOperator(libraries = {ALL})
+ public static final SqlFunction ACOSH =
+ SqlBasicFunction.create("ACOSH",
+ ReturnTypes.DOUBLE_NULLABLE,
+ OperandTypes.NUMERIC,
+ SqlFunctionCategory.NUMERIC);
+
+ /** The {@code ASINH(numeric)} function; returns the inverse hyperbolic sine of {@code value}. */
+ @LibraryOperator(libraries = {ALL})
+ public static final SqlFunction ASINH =
+ SqlBasicFunction.create("ASINH",
+ ReturnTypes.DOUBLE_NULLABLE,
+ OperandTypes.NUMERIC,
+ SqlFunctionCategory.NUMERIC);
+
+ /** The {@code ATANH(numeric)} function. returns the inverse hyperbolic tangent
Review Comment:
minor: I think you meant to have a `;` instead of `.` after "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
[GitHub] [calcite] zoudan commented on pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "zoudan (via GitHub)" <gi...@apache.org>.
zoudan commented on PR #3214:
URL: https://github.com/apache/calcite/pull/3214#issuecomment-1564085559
@rubenada Thanks, I have squashed the commits
--
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
[GitHub] [calcite] rubenada commented on a diff in pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on code in PR #3214:
URL: https://github.com/apache/calcite/pull/3214#discussion_r1203665979
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -1897,6 +1930,29 @@ public static double atan2(double b0, double b1) {
return Math.atan2(b0, b1);
}
+ // ATANH
+ /** SQL <code>ATANH</code> operator applied to BigDecimal values. */
+ public static double atanh(BigDecimal b) {
+ return atanh(b.doubleValue());
+ }
+
+ /** SQL <code>ATANH</code> operator applied to double values. */
+ public static double atanh(double b) {
+ if (b > 1 || b < -1) {
Review Comment:
According to [this](https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions) and [this](https://support.microsoft.com/en-us/office/atanh-function-3cd65768-0de7-4f1d-b312-d01c8c930d90), I think that 1 and -1 should also be forbidden:
```
if (b => 1 || b <= -1) {
throw new IllegalArgumentException(...);
}
```
--
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
[GitHub] [calcite] rubenada commented on a diff in pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on code in PR #3214:
URL: https://github.com/apache/calcite/pull/3214#discussion_r1203661166
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -1854,6 +1854,20 @@ public static double acos(double b0) {
return Math.acos(b0);
}
+ // ACOSH
+ /** SQL <code>ACOSH</code> operator applied to BigDecimal values. */
+ public static double acosh(BigDecimal b0) {
+ return acosh(b0.doubleValue());
+ }
+
+ /** SQL <code>ACOSH</code> operator applied to double values. */
+ public static double acosh(double b0) {
+ if (b0 < 1) {
+ throw new IllegalArgumentException("Input parameter of acosh cannot be less than 1!");
+ }
+ return Math.log(Math.sqrt(b0 * b0 - 1.0) + b0);
Review Comment:
Super-nitpick: for consistency with the other methods, I think we should use `1.0d` instead of `1.0` 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
[GitHub] [calcite] rubenada commented on pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada commented on PR #3214:
URL: https://github.com/apache/calcite/pull/3214#issuecomment-1562918294
@tanclary I see you have participated on other trigonometric-related PRs, would you like to take a look at this one?
I think it is in a good shape and I will proceed to merge (after squashing commits)
--
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
[GitHub] [calcite] rubenada merged pull request #3214: [CALCITE-5608] Implement ASINH, ACOSH, ATANH functions
Posted by "rubenada (via GitHub)" <gi...@apache.org>.
rubenada merged PR #3214:
URL: https://github.com/apache/calcite/pull/3214
--
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