[GitHub] [calcite] tanclary commented on a diff in pull request #3303: [CALCITE-5827] Add IS_INF and IS_NAN functions (enabled in BigQuery l…

2023-08-07 Thread via GitHub


tanclary commented on code in PR #3303:
URL: https://github.com/apache/calcite/pull/3303#discussion_r1286101447


##
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##
@@ -6618,6 +6618,64 @@ private static void checkIf(SqlOperatorFixture f) {
 f.checkNull("pow(cast(null as integer), 2)");
   }
 
+  @Test void testInfinity() {
+final SqlOperatorFixture f = fixture();
+f.checkScalar("cast('Infinity' as double)", "Infinity",
+"DOUBLE NOT NULL");
+f.checkScalar("cast('-Infinity' as double)", "-Infinity",
+"DOUBLE NOT NULL");
+f.checkScalar("cast('Infinity' as real)", "Infinity",
+"REAL NOT NULL");
+f.checkScalar("cast('-Infinity' as real)", "-Infinity",
+"REAL NOT NULL");
+  }
+
+  @Test void testNaN() {
+final SqlOperatorFixture f = fixture();
+f.checkScalar("cast('NaN' as double)", "NaN",
+"DOUBLE NOT NULL");
+f.checkScalar("cast('NaN' as real)", "NaN",
+"REAL NOT NULL");
+  }
+
+  @Test void testIsInfFunc() {
+final SqlOperatorFixture f0 = fixture().setFor(SqlLibraryOperators.IS_INF);
+f0.checkFails("^is_inf(3)^",
+"No match found for function signature IS_INF\\(\\)",
+false);
+final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY);
+f.checkBoolean("is_inf(3)", false);
+f.checkBoolean("is_inf(1.2345)", false);
+f.checkBoolean("is_inf(cast('NaN' as double))", false);
+f.checkBoolean("is_inf(cast('NaN' as real))", false);
+f.checkBoolean("is_inf(cast('Infinity' as double))", true);
+f.checkBoolean("is_inf(cast('Infinity' as float))", true);
+f.checkBoolean("is_inf(cast('Infinity' as real))", true);
+f.checkBoolean("is_inf(cast('-Infinity' as double))", true);
+f.checkBoolean("is_inf(cast('-Infinity' as float))", true);
+f.checkBoolean("is_inf(cast('-Infinity' as real))", true);
+f.checkNull("is_inf(cast(null as double))");
+  }
+
+  @Test void testIsNaNFunc() {
+final SqlOperatorFixture f0 = fixture().setFor(SqlLibraryOperators.IS_NAN);
+f0.checkFails("^is_nan(3)^",
+"No match found for function signature IS_NAN\\(\\)",
+false);
+final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY);
+f.checkBoolean("is_nan(3)", false);
+f.checkBoolean("is_nan(1.2345)", false);
+f.checkBoolean("is_nan(cast('Infinity' as double))", false);
+f.checkBoolean("is_nan(cast('Infinity' as float))", false);
+f.checkBoolean("is_nan(cast('Infinity' as real))", false);
+f.checkBoolean("is_nan(cast('-Infinity' as double))", false);
+f.checkBoolean("is_inf(cast('-Infinity' as float))", false);

Review Comment:
   Yes thanks!



-- 
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-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] tanclary commented on a diff in pull request #3303: [CALCITE-5827] Add IS_INF and IS_NAN functions (enabled in BigQuery l…

2023-08-03 Thread via GitHub


tanclary commented on code in PR #3303:
URL: https://github.com/apache/calcite/pull/3303#discussion_r1283866205


##
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##
@@ -2106,6 +2106,11 @@ public static boolean isInf(double b0) {
 return Double.isInfinite(b0);
   }
 
+  /** SQL IS_INF operator applied to float values. */

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-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] tanclary commented on a diff in pull request #3303: [CALCITE-5827] Add IS_INF and IS_NAN functions (enabled in BigQuery l…

2023-07-18 Thread via GitHub


tanclary commented on code in PR #3303:
URL: https://github.com/apache/calcite/pull/3303#discussion_r1266940303


##
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##
@@ -6618,6 +6618,60 @@ private static void checkIf(SqlOperatorFixture f) {
 f.checkNull("pow(cast(null as integer), 2)");
   }
 
+  @Test void testInfinity() {
+final SqlOperatorFixture f = fixture();
+f.checkScalar("CAST('Infinity' AS DOUBLE)", "Infinity",

Review Comment:
   Done, let me know if you have other suggestions!



-- 
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-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] tanclary commented on a diff in pull request #3303: [CALCITE-5827] Add IS_INF and IS_NAN functions (enabled in BigQuery l…

2023-07-11 Thread via GitHub


tanclary commented on code in PR #3303:
URL: https://github.com/apache/calcite/pull/3303#discussion_r1260312377


##
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##
@@ -2106,6 +2106,11 @@ public static boolean isInf(double b0) {
 return Double.isInfinite(b0);
   }
 
+  /** SQL IS_INF operator applied to float values. */

Review Comment:
   This was actually not right. The tests fail because if you remove the 
`float` methods, they use the BigDecimal functions which do not recognize 
`Infinity` and `NaN`



-- 
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-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] tanclary commented on a diff in pull request #3303: [CALCITE-5827] Add IS_INF and IS_NAN functions (enabled in BigQuery l…

2023-07-11 Thread via GitHub


tanclary commented on code in PR #3303:
URL: https://github.com/apache/calcite/pull/3303#discussion_r1260289501


##
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##
@@ -2106,6 +2106,11 @@ public static boolean isInf(double b0) {
 return Double.isInfinite(b0);
   }
 
+  /** SQL IS_INF operator applied to float values. */

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-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] tanclary commented on a diff in pull request #3303: [CALCITE-5827] Add IS_INF and IS_NAN functions (enabled in BigQuery l…

2023-07-11 Thread via GitHub


tanclary commented on code in PR #3303:
URL: https://github.com/apache/calcite/pull/3303#discussion_r1260109468


##
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##
@@ -6618,6 +6618,34 @@ private static void checkIf(SqlOperatorFixture f) {
 f.checkNull("pow(cast(null as integer), 2)");
   }
 
+  @Test void testIsInfFunc() {
+final SqlOperatorFixture f0 = fixture().setFor(SqlLibraryOperators.IS_INF);
+f0.checkFails("^is_inf(3)^",
+"No match found for function signature IS_INF\\(\\)",
+false);
+final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY);
+f.checkBoolean("is_inf(3)", false);
+f.checkBoolean("is_inf(1.2345)", false);
+f.checkBoolean("is_inf(cast('NaN' as double))", false);
+f.checkBoolean("is_inf(cast('Infinity' as double))", true);
+f.checkBoolean("is_inf(cast('-Infinity' as double))", true);

Review Comment:
   Added tests for REAL and Infinity/NaN



-- 
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-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] tanclary commented on a diff in pull request #3303: [CALCITE-5827] Add IS_INF and IS_NAN functions (enabled in BigQuery l…

2023-07-11 Thread via GitHub


tanclary commented on code in PR #3303:
URL: https://github.com/apache/calcite/pull/3303#discussion_r1260109063


##
site/_docs/reference.md:
##
@@ -2731,6 +2731,8 @@ BigQuery's type system uses confusingly different names 
for types and functions:
 | b | IFNULL(value1, value2) | Equivalent to 
`NVL(value1, value2)`
 | b o | INSTR(string, substring [, from [, occurrence ] ]) | Returns the 
position of *substring* in *string*, searching starting at *from* (default 1), 
and until locating the nth *occurrence* (default 1) of *substring*
 | m | INSTR(string, substring)   | Equivalent to 
`POSITION(substring IN string)`
+| b | IS_INF(value)  | Returns whether *value* 
is infinite
+| b | IS_NAN(value)  | Returns whether *value* 
is NaN

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-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [calcite] tanclary commented on a diff in pull request #3303: [CALCITE-5827] Add IS_INF and IS_NAN functions (enabled in BigQuery l…

2023-07-10 Thread via GitHub


tanclary commented on code in PR #3303:
URL: https://github.com/apache/calcite/pull/3303#discussion_r1258640714


##
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##
@@ -6618,6 +6618,34 @@ private static void checkIf(SqlOperatorFixture f) {
 f.checkNull("pow(cast(null as integer), 2)");
   }
 
+  @Test void testIsInfFunc() {
+final SqlOperatorFixture f0 = fixture().setFor(SqlLibraryOperators.IS_INF);
+f0.checkFails("^is_inf(3)^",
+"No match found for function signature IS_INF\\(\\)",
+false);
+final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY);
+f.checkBoolean("is_inf(3)", false);
+f.checkBoolean("is_inf(1.2345)", false);
+f.checkBoolean("is_inf(cast('NaN' as double))", false);
+f.checkBoolean("is_inf(cast('Infinity' as double))", true);
+f.checkBoolean("is_inf(cast('-Infinity' as double))", true);
+f.checkNull("is_inf(cast(null as double))");
+  }
+
+  @Test void testIsNaNFunc() {
+final SqlOperatorFixture f0 = fixture().setFor(SqlLibraryOperators.IS_NAN);
+f0.checkFails("^is_nan(3)^",

Review Comment:
   Yep!



-- 
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-unsubscr...@calcite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org