Re: [PR] [CALCITE-6224] Add LOG2 function (enabled in Mysql, Spark library) [calcite]
caicancai commented on code in PR #3648: URL: https://github.com/apache/calcite/pull/3648#discussion_r1481029377 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6215,6 +6215,71 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { f.checkNull("log(10, cast(null as real))"); } + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6224;>[CALCITE-6224] + * Add LOG@ function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +final Consumer consumer = f -> { + f.setFor(SqlLibraryOperators.LOG2); + f.checkScalarApprox("log2(2)", "DOUBLE NOT NULL", + isWithin(1.0, 0.01)); + f.checkScalarApprox("log2(4)", "DOUBLE NOT NULL", + isWithin(2.0, 0.01)); + f.checkScalarApprox("log2(65536)", "DOUBLE NOT NULL", + isWithin(16.0, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(2/3)", "DOUBLE NOT NULL", + "-Infinity"); + f.checkScalarApprox("log2(2.2)", "DOUBLE NOT NULL", + "1.1375035237499351"); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + "-1.0"); + f.checkScalarApprox("log2(3)", "DOUBLE NOT NULL", + isWithin(1.5849625007211563, 0.01)); + f.checkNull("log2(cast(null as real))"); +}; +f0.forEachLibrary(list(SqlLibrary.MYSQL, SqlLibrary.SPARK), consumer); + } + + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6232;>[CALCITE-6232] + * Using fractions in LOG function does not return correct results. */ + @Test void testLogFuncByConvert() { +final SqlOperatorFixture f0 = fixture(); +f0.setFor(SqlLibraryOperators.LOG, VmName.EXPAND); +final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY); +f.checkScalarApprox("log(2.0/3, 2)", "DOUBLE NOT NULL", Review Comment: Since my pr has a conflict, I will close it first, and then I will raise a pr after solving the problem of log2(0) returning null. 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
Re: [PR] [CALCITE-6224] Add LOG2 function (enabled in Mysql, Spark library) [calcite]
caicancai closed pull request #3648: [CALCITE-6224] Add LOG2 function (enabled in Mysql, Spark library) URL: https://github.com/apache/calcite/pull/3648 -- 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
Re: [PR] [CALCITE-6224] Add LOG2 function (enabled in Mysql, Spark library) [calcite]
caicancai commented on code in PR #3648: URL: https://github.com/apache/calcite/pull/3648#discussion_r1481028118 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6215,6 +6215,71 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { f.checkNull("log(10, cast(null as real))"); } + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6224;>[CALCITE-6224] + * Add LOG@ function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +final Consumer consumer = f -> { + f.setFor(SqlLibraryOperators.LOG2); + f.checkScalarApprox("log2(2)", "DOUBLE NOT NULL", + isWithin(1.0, 0.01)); + f.checkScalarApprox("log2(4)", "DOUBLE NOT NULL", + isWithin(2.0, 0.01)); + f.checkScalarApprox("log2(65536)", "DOUBLE NOT NULL", + isWithin(16.0, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(2/3)", "DOUBLE NOT NULL", + "-Infinity"); + f.checkScalarApprox("log2(2.2)", "DOUBLE NOT NULL", + "1.1375035237499351"); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + "-1.0"); + f.checkScalarApprox("log2(3)", "DOUBLE NOT NULL", + isWithin(1.5849625007211563, 0.01)); + f.checkNull("log2(cast(null as real))"); +}; +f0.forEachLibrary(list(SqlLibrary.MYSQL, SqlLibrary.SPARK), consumer); + } + + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6232;>[CALCITE-6232] + * Using fractions in LOG function does not return correct results. */ + @Test void testLogFuncByConvert() { +final SqlOperatorFixture f0 = fixture(); +f0.setFor(SqlLibraryOperators.LOG, VmName.EXPAND); +final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY); +f.checkScalarApprox("log(2.0/3, 2)", "DOUBLE NOT NULL", Review Comment: I probably understand what you mean. What you mean is that if you input types such as string and boolean that are not numbers, an error should be reported. -- 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
Re: [PR] [CALCITE-6238] Exception while evaluating ROUND function [calcite]
mihaibudiu commented on code in PR #3672: URL: https://github.com/apache/calcite/pull/3672#discussion_r1480850427 ## core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java: ## @@ -393,6 +393,12 @@ public static SqlOperandTypeChecker variadic( // Second operand optional (operand index 0, 1) number -> number == 1); + public static final SqlOperandTypeChecker NUMERIC_INT32 = + sequence("ROUND(, )", + family(SqlTypeFamily.NUMERIC), + // Only 32-bit integer allowed for the second argument + new TypeNameChecker(SqlTypeName.INTEGER)); Review Comment: These rules explain how ROUND is typechecked. These rules do not say anything about implicit casts, only about legal arguments accepted by this function. I believe that type coercion is the one that inserts the implicit casts if they are necessary. -- 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
Re: [PR] [CALCITE-6238] Exception while evaluating ROUND function [calcite]
macroguo-ghy commented on code in PR #3672: URL: https://github.com/apache/calcite/pull/3672#discussion_r1480844203 ## core/src/main/java/org/apache/calcite/sql/type/OperandTypes.java: ## @@ -393,6 +393,12 @@ public static SqlOperandTypeChecker variadic( // Second operand optional (operand index 0, 1) number -> number == 1); + public static final SqlOperandTypeChecker NUMERIC_INT32 = + sequence("ROUND(, )", + family(SqlTypeFamily.NUMERIC), + // Only 32-bit integer allowed for the second argument + new TypeNameChecker(SqlTypeName.INTEGER)); Review Comment: It's okay for me to use `TypeNameChecker`, but if Calcite implicitly casts other integer types to 32-bit integer, it would be better for this case. -- 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
(calcite) branch main updated: [CALCITE-6241] Enable a few existing functions to Spark library
This is an automated email from the ASF dual-hosted git repository. guohongyu pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/calcite.git The following commit(s) were added to refs/heads/main by this push: new b5091fe94d [CALCITE-6241] Enable a few existing functions to Spark library b5091fe94d is described below commit b5091fe94d38ee952bde116ba6e04f00deb7308a Author: YiwenWu AuthorDate: Sat Feb 3 18:03:02 2024 +0800 [CALCITE-6241] Enable a few existing functions to Spark library Functions List: DECODE, NVL, IFNULL, LEN, LENGTH, LPAD, RPAD, LTRIM, RTRIM, ENDSWITH, STARTSWITH, GREATEST, LEAST, TRANSLATE, BOOL_AND, BOOL_OR, DATE_FROM_UNIX_DATE, UNIX_DATE, LEFT, REPEAT, RIGHT, SPACE TIMESTAMP_SECONDS, TIMESTAMP_MILLIS, TIMESTAMP_MICROS, UNIX_SECONDS, UNIX_MILLIS, UNIX_MICROS, MD5, SHA1, POW --- .../calcite/sql/fun/SqlLibraryOperators.java | 62 site/_docs/reference.md| 62 .../org/apache/calcite/test/SqlOperatorTest.java | 159 - 3 files changed, 151 insertions(+), 132 deletions(-) diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java b/core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java index d397f008b2..e8dac9d7a9 100644 --- a/core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java +++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java @@ -232,7 +232,7 @@ public abstract class SqlLibraryOperators { }; /** The "DECODE(v, v1, result1, [v2, result2, ...], resultN)" function. */ - @LibraryOperator(libraries = {ORACLE}) + @LibraryOperator(libraries = {ORACLE, SPARK}) public static final SqlFunction DECODE = SqlBasicFunction.create(SqlKind.DECODE, DECODE_RETURN_TYPE, OperandTypes.VARIADIC); @@ -263,7 +263,7 @@ public abstract class SqlLibraryOperators { } /** The "NVL(value, value)" function. */ - @LibraryOperator(libraries = {ORACLE}) + @LibraryOperator(libraries = {ORACLE, SPARK}) public static final SqlBasicFunction NVL = SqlBasicFunction.create(SqlKind.NVL, ReturnTypes.LEAST_RESTRICTIVE @@ -271,16 +271,16 @@ public abstract class SqlLibraryOperators { OperandTypes.SAME_SAME); /** The "IFNULL(value, value)" function. */ - @LibraryOperator(libraries = {BIG_QUERY}) + @LibraryOperator(libraries = {BIG_QUERY, SPARK}) public static final SqlFunction IFNULL = NVL.withName("IFNULL"); /** The "LEN(string)" function. */ - @LibraryOperator(libraries = {SNOWFLAKE}) + @LibraryOperator(libraries = {SNOWFLAKE, SPARK}) public static final SqlFunction LEN = SqlStdOperatorTable.CHAR_LENGTH.withName("LEN"); /** The "LENGTH(string)" function. */ - @LibraryOperator(libraries = {BIG_QUERY, SNOWFLAKE}) + @LibraryOperator(libraries = {BIG_QUERY, SNOWFLAKE, SPARK}) public static final SqlFunction LENGTH = SqlStdOperatorTable.CHAR_LENGTH.withName("LENGTH"); @@ -291,7 +291,7 @@ public abstract class SqlLibraryOperators { } /** The "LPAD(original_value, return_length[, pattern])" function. */ - @LibraryOperator(libraries = {BIG_QUERY, ORACLE}) + @LibraryOperator(libraries = {BIG_QUERY, ORACLE, SPARK}) public static final SqlFunction LPAD = SqlBasicFunction.create( "LPAD", @@ -300,7 +300,7 @@ public abstract class SqlLibraryOperators { SqlFunctionCategory.STRING); /** The "RPAD(original_value, return_length[, pattern])" function. */ - @LibraryOperator(libraries = {BIG_QUERY, ORACLE}) + @LibraryOperator(libraries = {BIG_QUERY, ORACLE, SPARK}) public static final SqlFunction RPAD = SqlBasicFunction.create( "RPAD", @@ -309,7 +309,7 @@ public abstract class SqlLibraryOperators { SqlFunctionCategory.STRING); /** The "LTRIM(string)" function. */ - @LibraryOperator(libraries = {BIG_QUERY, ORACLE}) + @LibraryOperator(libraries = {BIG_QUERY, ORACLE, SPARK}) public static final SqlFunction LTRIM = SqlBasicFunction.create(SqlKind.LTRIM, ReturnTypes.ARG0.andThen(SqlTypeTransforms.TO_NULLABLE) @@ -318,7 +318,7 @@ public abstract class SqlLibraryOperators { .withFunctionType(SqlFunctionCategory.STRING); /** The "RTRIM(string)" function. */ - @LibraryOperator(libraries = {BIG_QUERY, ORACLE}) + @LibraryOperator(libraries = {BIG_QUERY, ORACLE, SPARK}) public static final SqlFunction RTRIM = SqlBasicFunction.create(SqlKind.RTRIM, ReturnTypes.ARG0.andThen(SqlTypeTransforms.TO_NULLABLE) @@ -373,7 +373,7 @@ public abstract class SqlLibraryOperators { OperandTypes.STRING_SAME_SAME); /** The "ENDSWITH(value1, value2)" function (Snowflake). */ - @LibraryOperator(libraries = {SNOWFLAKE}) + @LibraryOperator(libraries = {SNOWFLAKE, SPARK}) public static final SqlFunction ENDSWITH = ENDS_WITH.withName("ENDSWITH"); /** The
Re: [PR] [CALCITE-6241] Enable a few existing functions to Spark library [calcite]
macroguo-ghy merged PR #3669: URL: https://github.com/apache/calcite/pull/3669 -- 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
(calcite) branch main updated: [CALCITE-6223] Add MAP_CONTAINS_KEY function (enabled in Spark library)
This is an automated email from the ASF dual-hosted git repository. guohongyu pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/calcite.git The following commit(s) were added to refs/heads/main by this push: new cf91b789d1 [CALCITE-6223] Add MAP_CONTAINS_KEY function (enabled in Spark library) cf91b789d1 is described below commit cf91b789d174dd72119cfbe46a646deeab753c7f Author: caicancai <2356672...@qq.com> AuthorDate: Thu Jan 25 16:16:47 2024 +0800 [CALCITE-6223] Add MAP_CONTAINS_KEY function (enabled in Spark library) --- .../calcite/adapter/enumerable/RexImpTable.java| 2 + .../org/apache/calcite/runtime/SqlFunctions.java | 5 +++ .../main/java/org/apache/calcite/sql/SqlKind.java | 3 ++ .../calcite/sql/fun/SqlLibraryOperators.java | 7 .../calcite/sql/type/NonNullableAccessors.java | 6 +++ .../org/apache/calcite/sql/type/OperandTypes.java | 45 ++ .../org/apache/calcite/util/BuiltInMethod.java | 1 + site/_docs/reference.md| 1 + .../org/apache/calcite/test/SqlOperatorTest.java | 37 ++ 9 files changed, 107 insertions(+) diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java index 71c65fb599..220d33f425 100644 --- a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java +++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java @@ -213,6 +213,7 @@ import static org.apache.calcite.sql.fun.SqlLibraryOperators.LOGICAL_OR; import static org.apache.calcite.sql.fun.SqlLibraryOperators.LPAD; import static org.apache.calcite.sql.fun.SqlLibraryOperators.MAP; import static org.apache.calcite.sql.fun.SqlLibraryOperators.MAP_CONCAT; +import static org.apache.calcite.sql.fun.SqlLibraryOperators.MAP_CONTAINS_KEY; import static org.apache.calcite.sql.fun.SqlLibraryOperators.MAP_ENTRIES; import static org.apache.calcite.sql.fun.SqlLibraryOperators.MAP_FROM_ARRAYS; import static org.apache.calcite.sql.fun.SqlLibraryOperators.MAP_FROM_ENTRIES; @@ -844,6 +845,7 @@ public class RexImpTable { defineMethod(ARRAYS_ZIP, BuiltInMethod.ARRAYS_ZIP.method, NullPolicy.ANY); defineMethod(EXISTS, BuiltInMethod.EXISTS.method, NullPolicy.ANY); defineMethod(MAP_CONCAT, BuiltInMethod.MAP_CONCAT.method, NullPolicy.ANY); + defineMethod(MAP_CONTAINS_KEY, BuiltInMethod.MAP_CONTAINS_KEY.method, NullPolicy.ANY); defineMethod(MAP_ENTRIES, BuiltInMethod.MAP_ENTRIES.method, NullPolicy.STRICT); defineMethod(MAP_KEYS, BuiltInMethod.MAP_KEYS.method, NullPolicy.STRICT); defineMethod(MAP_VALUES, BuiltInMethod.MAP_VALUES.method, NullPolicy.STRICT); diff --git a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java index 99bfcfb281..6e9a29463f 100644 --- a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java +++ b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java @@ -5446,6 +5446,11 @@ public class SqlFunctions { return new ArrayList<>(map.values()); } + /** Support the MAP_CONTAINS_KEY function. */ + public static Boolean mapContainsKey(Map map, Object key) { +return map.containsKey(key); + } + /** Support the MAP_FROM_ARRAYS function. */ public static Map mapFromArrays(List keysArray, List valuesArray) { if (keysArray.size() != valuesArray.size()) { diff --git a/core/src/main/java/org/apache/calcite/sql/SqlKind.java b/core/src/main/java/org/apache/calcite/sql/SqlKind.java index 5375ee6748..ae44f495a9 100644 --- a/core/src/main/java/org/apache/calcite/sql/SqlKind.java +++ b/core/src/main/java/org/apache/calcite/sql/SqlKind.java @@ -779,6 +779,9 @@ public enum SqlKind { /** {@code MAP_VALUES} function (Spark semantics). */ MAP_VALUES, + /** {@code MAP_CONTAINS_KEY} function (Spark semantics). */ + MAP_CONTAINS_KEY, + /** {@code MAP_FROM_ARRAYS} function (Spark semantics). */ MAP_FROM_ARRAYS, diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java b/core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java index 093a25b3a3..d397f008b2 100644 --- a/core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java +++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java @@ -1468,6 +1468,13 @@ public abstract class SqlLibraryOperators { ReturnTypes.TO_MAP_VALUES_NULLABLE, OperandTypes.MAP); + /** The "MAP_CONTAINS_KEY(map, key)" function. */ + @LibraryOperator(libraries = {SPARK}) + public static final SqlFunction MAP_CONTAINS_KEY = + SqlBasicFunction.create(SqlKind.MAP_CONTAINS_KEY, + ReturnTypes.BOOLEAN_NULLABLE, + OperandTypes.MAP_KEY); + private static RelDataType deriveTypeMapFromArrays(SqlOperatorBinding opBinding) { final
Re: [PR] [CALCITE-6223] Add MAP_CONTAINS_KEY function (enabled in Spark library) [calcite]
macroguo-ghy merged PR #3655: URL: https://github.com/apache/calcite/pull/3655 -- 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
Re: [PR] [CALCITE-6228] ELEMENT function infers incorrect return type [calcite]
mihaibudiu commented on code in PR #3650: URL: https://github.com/apache/calcite/pull/3650#discussion_r1480687499 ## core/src/main/java/org/apache/calcite/sql/type/ReturnTypes.java: ## @@ -620,6 +620,13 @@ public static SqlCall stripSeparator(SqlCall call) { public static final SqlReturnTypeInference MULTISET_ELEMENT_NULLABLE = Review Comment: Since it is public I was assuming it may be used in other third-party libraries. What is the policy about removing public fields in Calcite? -- 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
Re: [PR] [CALCITE-6239] Add a postgis dialect that supports ST functions [calcite]
sonarcloud[bot] commented on PR #3668: URL: https://github.com/apache/calcite/pull/3668#issuecomment-1930960796 ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3668) **Quality Gate passed** The SonarCloud Quality Gate passed, but some issues were introduced. [6 New issues](https://sonarcloud.io/project/issues?id=apache_calcite=3668=false=true) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3668=false=true) [60.9% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3668=new_coverage=list) [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3668=new_duplicated_lines_density=list) [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite=3668) -- 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
Re: [PR] [CALCITE-6228] ELEMENT function infers incorrect return type [calcite]
YiwenWu commented on code in PR #3650: URL: https://github.com/apache/calcite/pull/3650#discussion_r1480658861 ## core/src/main/java/org/apache/calcite/sql/type/ReturnTypes.java: ## @@ -620,6 +620,13 @@ public static SqlCall stripSeparator(SqlCall call) { public static final SqlReturnTypeInference MULTISET_ELEMENT_NULLABLE = Review Comment: Since only the ELEMENT operator is used, I think it can be removed -- 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
Re: [PR] [CALCITE-6238] Exception while evaluating ROUND function [calcite]
sonarcloud[bot] commented on PR #3672: URL: https://github.com/apache/calcite/pull/3672#issuecomment-1930879137 ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3672) **Quality Gate passed** Kudos, no new issues were introduced! [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite=3672=false=true) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3672=false=true) [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3672=new_coverage=list) [19.4% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3672=new_duplicated_lines_density=list) [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite=3672) -- 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
Re: [PR] [CALCITE-6214] Remove DISTINCT in aggregate function if field is unique [calcite]
mihaibudiu commented on code in PR #3641: URL: https://github.com/apache/calcite/pull/3641#discussion_r1480422181 ## core/src/main/java/org/apache/calcite/tools/RelBuilder.java: ## @@ -2525,6 +2529,29 @@ private RelBuilder aggregate_(GroupKeyImpl groupKey, return project(projects.transform((i, name) -> aliasMaybe(field(i), name))); } + /** + * Removed redundant distinct if an input is already unique. Review Comment: I would document that this is specifically for aggregates. And perhaps a better function name would be removeRedundantAggregateDistinct. ## core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml: ## @@ -6343,6 +6343,161 @@ LogicalAggregate(group=[{0}], CNT=[COUNT()]) LogicalFilter(condition=[>(ITEM($0, 'N_NATIONKEY'), 5)]) LogicalProject(**=[$0]) LogicalTableScan(table=[[CATALOG, SALES, NATION]]) +]]> + + + Review Comment: Where is the corresponding test? ## core/src/main/java/org/apache/calcite/tools/RelBuilder.java: ## @@ -4902,6 +4929,18 @@ public interface Config { /** Sets {@link #convertCorrelateToJoin()}. */ Config withConvertCorrelateToJoin(boolean convertCorrelateToJoin); + +/** Whether to save the distinct if we know that the input is + * already unique; default true. */ +@Value.Default +default boolean redundantDistinct() { Review Comment: This flag is a little unintuitive, since it *inhibits* the optimization rather than enabling it. All the other similar flags are in the opposite way. ## core/src/test/resources/org/apache/calcite/test/SqlToRelConverterTest.xml: ## @@ -6343,6 +6343,161 @@ LogicalAggregate(group=[{0}], CNT=[COUNT()]) LogicalFilter(condition=[>(ITEM($0, 'N_NATIONKEY'), 5)]) LogicalProject(**=[$0]) LogicalTableScan(table=[[CATALOG, SALES, NATION]]) +]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Re: [PR] [CALCITE-6224] Add LOG2 function (enabled in Mysql, Spark library) [calcite]
tanclary commented on code in PR #3648: URL: https://github.com/apache/calcite/pull/3648#discussion_r1480254671 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6215,6 +6215,71 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { f.checkNull("log(10, cast(null as real))"); } + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6224;>[CALCITE-6224] + * Add LOG@ function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +final Consumer consumer = f -> { + f.setFor(SqlLibraryOperators.LOG2); + f.checkScalarApprox("log2(2)", "DOUBLE NOT NULL", + isWithin(1.0, 0.01)); + f.checkScalarApprox("log2(4)", "DOUBLE NOT NULL", + isWithin(2.0, 0.01)); + f.checkScalarApprox("log2(65536)", "DOUBLE NOT NULL", + isWithin(16.0, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(2/3)", "DOUBLE NOT NULL", + "-Infinity"); + f.checkScalarApprox("log2(2.2)", "DOUBLE NOT NULL", + "1.1375035237499351"); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + "-1.0"); + f.checkScalarApprox("log2(3)", "DOUBLE NOT NULL", + isWithin(1.5849625007211563, 0.01)); + f.checkNull("log2(cast(null as real))"); +}; +f0.forEachLibrary(list(SqlLibrary.MYSQL, SqlLibrary.SPARK), consumer); + } + + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6232;>[CALCITE-6232] + * Using fractions in LOG function does not return correct results. */ + @Test void testLogFuncByConvert() { +final SqlOperatorFixture f0 = fixture(); +f0.setFor(SqlLibraryOperators.LOG, VmName.EXPAND); +final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY); +f.checkScalarApprox("log(2.0/3, 2)", "DOUBLE NOT NULL", Review Comment: The examples you gave above are **not** negative tests (aside from the `null` one). Please read my previous comment. What do you expect of the user? It is a numeric function that is designed to support numeric arguments. Anything outside of that is unexpected. -- 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
Re: [PR] [CALCITE-6224] Add LOG2 function (enabled in Mysql, Spark library) [calcite]
tanclary commented on code in PR #3648: URL: https://github.com/apache/calcite/pull/3648#discussion_r1480247792 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6215,6 +6215,71 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { f.checkNull("log(10, cast(null as real))"); } + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6224;>[CALCITE-6224] + * Add LOG@ function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +final Consumer consumer = f -> { + f.setFor(SqlLibraryOperators.LOG2); + f.checkScalarApprox("log2(2)", "DOUBLE NOT NULL", + isWithin(1.0, 0.01)); + f.checkScalarApprox("log2(4)", "DOUBLE NOT NULL", + isWithin(2.0, 0.01)); + f.checkScalarApprox("log2(65536)", "DOUBLE NOT NULL", + isWithin(16.0, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(2/3)", "DOUBLE NOT NULL", + "-Infinity"); + f.checkScalarApprox("log2(2.2)", "DOUBLE NOT NULL", + "1.1375035237499351"); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + "-1.0"); + f.checkScalarApprox("log2(3)", "DOUBLE NOT NULL", + isWithin(1.5849625007211563, 0.01)); + f.checkNull("log2(cast(null as real))"); +}; +f0.forEachLibrary(list(SqlLibrary.MYSQL, SqlLibrary.SPARK), consumer); + } + + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6232;>[CALCITE-6232] + * Using fractions in LOG function does not return correct results. */ + @Test void testLogFuncByConvert() { +final SqlOperatorFixture f0 = fixture(); +f0.setFor(SqlLibraryOperators.LOG, VmName.EXPAND); +final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY); +f.checkScalarApprox("log(2.0/3, 2)", "DOUBLE NOT NULL", Review Comment: Yes, you need to adjust/add behavior s.t. when this function is used for these dialects, it follows the proper behavior. -- 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
Re: [PR] [CALCITE-6224] Add LOG2 function (enabled in Mysql, Spark library) [calcite]
caicancai commented on code in PR #3648: URL: https://github.com/apache/calcite/pull/3648#discussion_r1480054578 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6215,6 +6215,71 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { f.checkNull("log(10, cast(null as real))"); } + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6224;>[CALCITE-6224] + * Add LOG@ function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +final Consumer consumer = f -> { + f.setFor(SqlLibraryOperators.LOG2); + f.checkScalarApprox("log2(2)", "DOUBLE NOT NULL", + isWithin(1.0, 0.01)); + f.checkScalarApprox("log2(4)", "DOUBLE NOT NULL", + isWithin(2.0, 0.01)); + f.checkScalarApprox("log2(65536)", "DOUBLE NOT NULL", + isWithin(16.0, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(2/3)", "DOUBLE NOT NULL", + "-Infinity"); + f.checkScalarApprox("log2(2.2)", "DOUBLE NOT NULL", + "1.1375035237499351"); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + "-1.0"); + f.checkScalarApprox("log2(3)", "DOUBLE NOT NULL", + isWithin(1.5849625007211563, 0.01)); + f.checkNull("log2(cast(null as real))"); +}; +f0.forEachLibrary(list(SqlLibrary.MYSQL, SqlLibrary.SPARK), consumer); + } + + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6232;>[CALCITE-6232] + * Using fractions in LOG function does not return correct results. */ + @Test void testLogFuncByConvert() { +final SqlOperatorFixture f0 = fixture(); +f0.setFor(SqlLibraryOperators.LOG, VmName.EXPAND); +final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY); +f.checkScalarApprox("log(2.0/3, 2)", "DOUBLE NOT NULL", Review Comment: https://github.com/apache/calcite/pull/3669, It seems that there should be the same situation -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] [CALCITE-6224] Add LOG2 function (enabled in Mysql, Spark library) [calcite]
caicancai commented on code in PR #3648: URL: https://github.com/apache/calcite/pull/3648#discussion_r1480048466 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6215,6 +6215,71 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { f.checkNull("log(10, cast(null as real))"); } + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6224;>[CALCITE-6224] + * Add LOG@ function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +final Consumer consumer = f -> { + f.setFor(SqlLibraryOperators.LOG2); + f.checkScalarApprox("log2(2)", "DOUBLE NOT NULL", + isWithin(1.0, 0.01)); + f.checkScalarApprox("log2(4)", "DOUBLE NOT NULL", + isWithin(2.0, 0.01)); + f.checkScalarApprox("log2(65536)", "DOUBLE NOT NULL", + isWithin(16.0, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(2/3)", "DOUBLE NOT NULL", + "-Infinity"); + f.checkScalarApprox("log2(2.2)", "DOUBLE NOT NULL", + "1.1375035237499351"); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + "-1.0"); + f.checkScalarApprox("log2(3)", "DOUBLE NOT NULL", + isWithin(1.5849625007211563, 0.01)); + f.checkNull("log2(cast(null as real))"); +}; +f0.forEachLibrary(list(SqlLibrary.MYSQL, SqlLibrary.SPARK), consumer); + } + + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6232;>[CALCITE-6232] + * Using fractions in LOG function does not return correct results. */ + @Test void testLogFuncByConvert() { +final SqlOperatorFixture f0 = fixture(); +f0.setFor(SqlLibraryOperators.LOG, VmName.EXPAND); +final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY); +f.checkScalarApprox("log(2.0/3, 2)", "DOUBLE NOT NULL", Review Comment: Double.NaN == null? -- 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
Re: [PR] [CALCITE-6224] Add LOG2 function (enabled in Mysql, Spark library) [calcite]
caicancai commented on code in PR #3648: URL: https://github.com/apache/calcite/pull/3648#discussion_r1479946888 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6215,6 +6215,71 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { f.checkNull("log(10, cast(null as real))"); } + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6224;>[CALCITE-6224] + * Add LOG@ function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +final Consumer consumer = f -> { + f.setFor(SqlLibraryOperators.LOG2); + f.checkScalarApprox("log2(2)", "DOUBLE NOT NULL", + isWithin(1.0, 0.01)); + f.checkScalarApprox("log2(4)", "DOUBLE NOT NULL", + isWithin(2.0, 0.01)); + f.checkScalarApprox("log2(65536)", "DOUBLE NOT NULL", + isWithin(16.0, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(2/3)", "DOUBLE NOT NULL", + "-Infinity"); + f.checkScalarApprox("log2(2.2)", "DOUBLE NOT NULL", + "1.1375035237499351"); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + "-1.0"); + f.checkScalarApprox("log2(3)", "DOUBLE NOT NULL", + isWithin(1.5849625007211563, 0.01)); + f.checkNull("log2(cast(null as real))"); +}; +f0.forEachLibrary(list(SqlLibrary.MYSQL, SqlLibrary.SPARK), consumer); + } + + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6232;>[CALCITE-6232] + * Using fractions in LOG function does not return correct results. */ + @Test void testLogFuncByConvert() { +final SqlOperatorFixture f0 = fixture(); +f0.setFor(SqlLibraryOperators.LOG, VmName.EXPAND); +final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY); +f.checkScalarApprox("log(2.0/3, 2)", "DOUBLE NOT NULL", Review Comment: @mihaibudiu Or should we deal with this situation? log10(-1) and log10(0) -- 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
Re: [PR] [CALCITE-6224] Add LOG2 function (enabled in Mysql, Spark library) [calcite]
sonarcloud[bot] commented on PR #3648: URL: https://github.com/apache/calcite/pull/3648#issuecomment-1930051948 ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3648) **Quality Gate passed** The SonarCloud Quality Gate passed, but some issues were introduced. [1 New issue](https://sonarcloud.io/project/issues?id=apache_calcite=3648=false=true) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3648=false=true) [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3648=new_coverage=list) [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3648=new_duplicated_lines_density=list) [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite=3648) -- 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
Re: [PR] [CALCITE-6224] Add LOG2 function (enabled in Mysql, Spark library) [calcite]
caicancai commented on code in PR #3648: URL: https://github.com/apache/calcite/pull/3648#discussion_r1479946888 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6215,6 +6215,71 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { f.checkNull("log(10, cast(null as real))"); } + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6224;>[CALCITE-6224] + * Add LOG@ function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +final Consumer consumer = f -> { + f.setFor(SqlLibraryOperators.LOG2); + f.checkScalarApprox("log2(2)", "DOUBLE NOT NULL", + isWithin(1.0, 0.01)); + f.checkScalarApprox("log2(4)", "DOUBLE NOT NULL", + isWithin(2.0, 0.01)); + f.checkScalarApprox("log2(65536)", "DOUBLE NOT NULL", + isWithin(16.0, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(2/3)", "DOUBLE NOT NULL", + "-Infinity"); + f.checkScalarApprox("log2(2.2)", "DOUBLE NOT NULL", + "1.1375035237499351"); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + "-1.0"); + f.checkScalarApprox("log2(3)", "DOUBLE NOT NULL", + isWithin(1.5849625007211563, 0.01)); + f.checkNull("log2(cast(null as real))"); +}; +f0.forEachLibrary(list(SqlLibrary.MYSQL, SqlLibrary.SPARK), consumer); + } + + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6232;>[CALCITE-6232] + * Using fractions in LOG function does not return correct results. */ + @Test void testLogFuncByConvert() { +final SqlOperatorFixture f0 = fixture(); +f0.setFor(SqlLibraryOperators.LOG, VmName.EXPAND); +final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY); +f.checkScalarApprox("log(2.0/3, 2)", "DOUBLE NOT NULL", Review Comment: @mihaibudiu Or should we deal with this situation? log10(-1) and log10(0) -- 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
Re: [PR] [CALCITE-6224] Add LOG2 function (enabled in Mysql, Spark library) [calcite]
caicancai commented on code in PR #3648: URL: https://github.com/apache/calcite/pull/3648#discussion_r1479946888 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6215,6 +6215,71 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { f.checkNull("log(10, cast(null as real))"); } + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6224;>[CALCITE-6224] + * Add LOG@ function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +final Consumer consumer = f -> { + f.setFor(SqlLibraryOperators.LOG2); + f.checkScalarApprox("log2(2)", "DOUBLE NOT NULL", + isWithin(1.0, 0.01)); + f.checkScalarApprox("log2(4)", "DOUBLE NOT NULL", + isWithin(2.0, 0.01)); + f.checkScalarApprox("log2(65536)", "DOUBLE NOT NULL", + isWithin(16.0, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(2/3)", "DOUBLE NOT NULL", + "-Infinity"); + f.checkScalarApprox("log2(2.2)", "DOUBLE NOT NULL", + "1.1375035237499351"); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + "-1.0"); + f.checkScalarApprox("log2(3)", "DOUBLE NOT NULL", + isWithin(1.5849625007211563, 0.01)); + f.checkNull("log2(cast(null as real))"); +}; +f0.forEachLibrary(list(SqlLibrary.MYSQL, SqlLibrary.SPARK), consumer); + } + + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6232;>[CALCITE-6232] + * Using fractions in LOG function does not return correct results. */ + @Test void testLogFuncByConvert() { +final SqlOperatorFixture f0 = fixture(); +f0.setFor(SqlLibraryOperators.LOG, VmName.EXPAND); +final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY); +f.checkScalarApprox("log(2.0/3, 2)", "DOUBLE NOT NULL", Review Comment: @mihaibudiu Or should we deal with this situation? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] [CALCITE-6224] Add LOG2 function (enabled in Mysql, Spark library) [calcite]
caicancai commented on code in PR #3648: URL: https://github.com/apache/calcite/pull/3648#discussion_r1479946888 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6215,6 +6215,71 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { f.checkNull("log(10, cast(null as real))"); } + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6224;>[CALCITE-6224] + * Add LOG@ function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +final Consumer consumer = f -> { + f.setFor(SqlLibraryOperators.LOG2); + f.checkScalarApprox("log2(2)", "DOUBLE NOT NULL", + isWithin(1.0, 0.01)); + f.checkScalarApprox("log2(4)", "DOUBLE NOT NULL", + isWithin(2.0, 0.01)); + f.checkScalarApprox("log2(65536)", "DOUBLE NOT NULL", + isWithin(16.0, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(2/3)", "DOUBLE NOT NULL", + "-Infinity"); + f.checkScalarApprox("log2(2.2)", "DOUBLE NOT NULL", + "1.1375035237499351"); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + "-1.0"); + f.checkScalarApprox("log2(3)", "DOUBLE NOT NULL", + isWithin(1.5849625007211563, 0.01)); + f.checkNull("log2(cast(null as real))"); +}; +f0.forEachLibrary(list(SqlLibrary.MYSQL, SqlLibrary.SPARK), consumer); + } + + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6232;>[CALCITE-6232] + * Using fractions in LOG function does not return correct results. */ + @Test void testLogFuncByConvert() { +final SqlOperatorFixture f0 = fixture(); +f0.setFor(SqlLibraryOperators.LOG, VmName.EXPAND); +final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY); +f.checkScalarApprox("log(2.0/3, 2)", "DOUBLE NOT NULL", Review Comment: @mihaibudiu @tanclary Or should we deal with this situation? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] [CALCITE-6224] Add LOG2 function (enabled in Mysql, Spark library) [calcite]
caicancai commented on code in PR #3648: URL: https://github.com/apache/calcite/pull/3648#discussion_r1479946888 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6215,6 +6215,71 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { f.checkNull("log(10, cast(null as real))"); } + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6224;>[CALCITE-6224] + * Add LOG@ function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +final Consumer consumer = f -> { + f.setFor(SqlLibraryOperators.LOG2); + f.checkScalarApprox("log2(2)", "DOUBLE NOT NULL", + isWithin(1.0, 0.01)); + f.checkScalarApprox("log2(4)", "DOUBLE NOT NULL", + isWithin(2.0, 0.01)); + f.checkScalarApprox("log2(65536)", "DOUBLE NOT NULL", + isWithin(16.0, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(2/3)", "DOUBLE NOT NULL", + "-Infinity"); + f.checkScalarApprox("log2(2.2)", "DOUBLE NOT NULL", + "1.1375035237499351"); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + "-1.0"); + f.checkScalarApprox("log2(3)", "DOUBLE NOT NULL", + isWithin(1.5849625007211563, 0.01)); + f.checkNull("log2(cast(null as real))"); +}; +f0.forEachLibrary(list(SqlLibrary.MYSQL, SqlLibrary.SPARK), consumer); + } + + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6232;>[CALCITE-6232] + * Using fractions in LOG function does not return correct results. */ + @Test void testLogFuncByConvert() { +final SqlOperatorFixture f0 = fixture(); +f0.setFor(SqlLibraryOperators.LOG, VmName.EXPAND); +final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY); +f.checkScalarApprox("log(2.0/3, 2)", "DOUBLE NOT NULL", Review Comment: @mihaibudiu Or should we deal with this situation? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] [CALCITE-6224] Add LOG2 function (enabled in Mysql, Spark library) [calcite]
caicancai commented on code in PR #3648: URL: https://github.com/apache/calcite/pull/3648#discussion_r1479937474 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6215,6 +6215,71 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { f.checkNull("log(10, cast(null as real))"); } + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6224;>[CALCITE-6224] + * Add LOG@ function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +final Consumer consumer = f -> { + f.setFor(SqlLibraryOperators.LOG2); + f.checkScalarApprox("log2(2)", "DOUBLE NOT NULL", + isWithin(1.0, 0.01)); + f.checkScalarApprox("log2(4)", "DOUBLE NOT NULL", + isWithin(2.0, 0.01)); + f.checkScalarApprox("log2(65536)", "DOUBLE NOT NULL", + isWithin(16.0, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(2/3)", "DOUBLE NOT NULL", + "-Infinity"); + f.checkScalarApprox("log2(2.2)", "DOUBLE NOT NULL", + "1.1375035237499351"); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + "-1.0"); + f.checkScalarApprox("log2(3)", "DOUBLE NOT NULL", + isWithin(1.5849625007211563, 0.01)); + f.checkNull("log2(cast(null as real))"); +}; +f0.forEachLibrary(list(SqlLibrary.MYSQL, SqlLibrary.SPARK), consumer); + } + + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6232;>[CALCITE-6232] + * Using fractions in LOG function does not return correct results. */ + @Test void testLogFuncByConvert() { +final SqlOperatorFixture f0 = fixture(); +f0.setFor(SqlLibraryOperators.LOG, VmName.EXPAND); +final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY); +f.checkScalarApprox("log(2.0/3, 2)", "DOUBLE NOT NULL", Review Comment: My current idea is to add a judgment to the log function in sqlFunctions. If it is less than or equal to 0, it will return 0. But there is a problem, that is, log10 and log functions are adapted to the current calcite database. So what should we do? To solve this problem, we cannot guarantee that the results returned by the database will be the same. In other words, Should I write Sqlfunctions specifically for log2 ? -- 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
Re: [PR] [CALCITE-6224] Add LOG2 function (enabled in Mysql, Spark library) [calcite]
caicancai commented on code in PR #3648: URL: https://github.com/apache/calcite/pull/3648#discussion_r1479937474 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6215,6 +6215,71 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { f.checkNull("log(10, cast(null as real))"); } + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6224;>[CALCITE-6224] + * Add LOG@ function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +final Consumer consumer = f -> { + f.setFor(SqlLibraryOperators.LOG2); + f.checkScalarApprox("log2(2)", "DOUBLE NOT NULL", + isWithin(1.0, 0.01)); + f.checkScalarApprox("log2(4)", "DOUBLE NOT NULL", + isWithin(2.0, 0.01)); + f.checkScalarApprox("log2(65536)", "DOUBLE NOT NULL", + isWithin(16.0, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(2/3)", "DOUBLE NOT NULL", + "-Infinity"); + f.checkScalarApprox("log2(2.2)", "DOUBLE NOT NULL", + "1.1375035237499351"); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + "-1.0"); + f.checkScalarApprox("log2(3)", "DOUBLE NOT NULL", + isWithin(1.5849625007211563, 0.01)); + f.checkNull("log2(cast(null as real))"); +}; +f0.forEachLibrary(list(SqlLibrary.MYSQL, SqlLibrary.SPARK), consumer); + } + + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6232;>[CALCITE-6232] + * Using fractions in LOG function does not return correct results. */ + @Test void testLogFuncByConvert() { +final SqlOperatorFixture f0 = fixture(); +f0.setFor(SqlLibraryOperators.LOG, VmName.EXPAND); +final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY); +f.checkScalarApprox("log(2.0/3, 2)", "DOUBLE NOT NULL", Review Comment: My current idea is to add a judgment to the log function in sqlFunctions. If it is less than or equal to 0, it will return 0. But there is a problem, that is, log10 and log functions are adapted to the current calcite database. So what should we do? To solve this problem, we cannot guarantee that the results returned by the database will be the same. In other words, I should write Sqlfunctions specifically for log2 -- 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
Re: [PR] [CALCITE-6224] Add LOG2 function (enabled in Mysql, Spark library) [calcite]
caicancai commented on code in PR #3648: URL: https://github.com/apache/calcite/pull/3648#discussion_r1479917763 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6215,6 +6215,71 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { f.checkNull("log(10, cast(null as real))"); } + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6224;>[CALCITE-6224] + * Add LOG@ function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +final Consumer consumer = f -> { + f.setFor(SqlLibraryOperators.LOG2); + f.checkScalarApprox("log2(2)", "DOUBLE NOT NULL", + isWithin(1.0, 0.01)); + f.checkScalarApprox("log2(4)", "DOUBLE NOT NULL", + isWithin(2.0, 0.01)); + f.checkScalarApprox("log2(65536)", "DOUBLE NOT NULL", + isWithin(16.0, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(2/3)", "DOUBLE NOT NULL", + "-Infinity"); + f.checkScalarApprox("log2(2.2)", "DOUBLE NOT NULL", + "1.1375035237499351"); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + "-1.0"); + f.checkScalarApprox("log2(3)", "DOUBLE NOT NULL", + isWithin(1.5849625007211563, 0.01)); + f.checkNull("log2(cast(null as real))"); +}; +f0.forEachLibrary(list(SqlLibrary.MYSQL, SqlLibrary.SPARK), consumer); + } + + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6232;>[CALCITE-6232] + * Using fractions in LOG function does not return correct results. */ + @Test void testLogFuncByConvert() { +final SqlOperatorFixture f0 = fixture(); +f0.setFor(SqlLibraryOperators.LOG, VmName.EXPAND); +final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY); +f.checkScalarApprox("log(2.0/3, 2)", "DOUBLE NOT NULL", Review Comment: Hello, thank you very much for your suggestion. Regarding negative test, I think of the following case - log10(-1): When the parameter in log10 is a negative number - log10(null): When the parameters in log10 are empty - log10(-`Infinity`): When the parameter in log10 is -`Infinity` - log10(0): When the parameter in log10 is 0 I tested based on mysql. Only when log(0) and log10(-1), calcite cannot match the results in mysql. In mysql, both of them return NULL. When log10(0), calcite returns -`Infinity. `log10(-1) returns NaN ![2024-02-06 22-20-16屏幕截图](https://github.com/apache/calcite/assets/77189278/27b21670-5364-463c-b6dc-d750c46d7cd1) spark sql and mysql return the same results ![2024-02-06 22-30-32屏幕截图](https://github.com/apache/calcite/assets/77189278/91173a60-695d-409e-b325-3f91655c6d0d) -- 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
Re: [PR] [CALCITE-6224] Add LOG2 function (enabled in Mysql, Spark library) [calcite]
caicancai commented on code in PR #3648: URL: https://github.com/apache/calcite/pull/3648#discussion_r1479917763 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6215,6 +6215,71 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { f.checkNull("log(10, cast(null as real))"); } + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6224;>[CALCITE-6224] + * Add LOG@ function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +final Consumer consumer = f -> { + f.setFor(SqlLibraryOperators.LOG2); + f.checkScalarApprox("log2(2)", "DOUBLE NOT NULL", + isWithin(1.0, 0.01)); + f.checkScalarApprox("log2(4)", "DOUBLE NOT NULL", + isWithin(2.0, 0.01)); + f.checkScalarApprox("log2(65536)", "DOUBLE NOT NULL", + isWithin(16.0, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(2/3)", "DOUBLE NOT NULL", + "-Infinity"); + f.checkScalarApprox("log2(2.2)", "DOUBLE NOT NULL", + "1.1375035237499351"); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + "-1.0"); + f.checkScalarApprox("log2(3)", "DOUBLE NOT NULL", + isWithin(1.5849625007211563, 0.01)); + f.checkNull("log2(cast(null as real))"); +}; +f0.forEachLibrary(list(SqlLibrary.MYSQL, SqlLibrary.SPARK), consumer); + } + + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6232;>[CALCITE-6232] + * Using fractions in LOG function does not return correct results. */ + @Test void testLogFuncByConvert() { +final SqlOperatorFixture f0 = fixture(); +f0.setFor(SqlLibraryOperators.LOG, VmName.EXPAND); +final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY); +f.checkScalarApprox("log(2.0/3, 2)", "DOUBLE NOT NULL", Review Comment: Hello, thank you very much for your suggestion. Regarding negative test, I think of the following case - log10(-1): When the parameter in log10 is a negative number - log10(null): When the parameters in log10 are empty - log10(-`Infinity`): When the parameter in log10 is -`Infinity` - log10(0): When the parameter in log10 is 0 I tested based on mysql. Only when log(0) and log10(-1), calcite cannot match the results in mysql. In mysql, both of them return NULL. When log10(0), calcite returns -`Infinity. `log10(-1) returns NaN ![2024-02-06 22-20-16屏幕截图](https://github.com/apache/calcite/assets/77189278/27b21670-5364-463c-b6dc-d750c46d7cd1) spark sql and mysql return the same results -- 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
Re: [PR] [CALCITE-6224] Add LOG2 function (enabled in Mysql, Spark library) [calcite]
caicancai commented on code in PR #3648: URL: https://github.com/apache/calcite/pull/3648#discussion_r1479917763 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6215,6 +6215,71 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { f.checkNull("log(10, cast(null as real))"); } + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6224;>[CALCITE-6224] + * Add LOG@ function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +final Consumer consumer = f -> { + f.setFor(SqlLibraryOperators.LOG2); + f.checkScalarApprox("log2(2)", "DOUBLE NOT NULL", + isWithin(1.0, 0.01)); + f.checkScalarApprox("log2(4)", "DOUBLE NOT NULL", + isWithin(2.0, 0.01)); + f.checkScalarApprox("log2(65536)", "DOUBLE NOT NULL", + isWithin(16.0, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(2/3)", "DOUBLE NOT NULL", + "-Infinity"); + f.checkScalarApprox("log2(2.2)", "DOUBLE NOT NULL", + "1.1375035237499351"); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + "-1.0"); + f.checkScalarApprox("log2(3)", "DOUBLE NOT NULL", + isWithin(1.5849625007211563, 0.01)); + f.checkNull("log2(cast(null as real))"); +}; +f0.forEachLibrary(list(SqlLibrary.MYSQL, SqlLibrary.SPARK), consumer); + } + + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6232;>[CALCITE-6232] + * Using fractions in LOG function does not return correct results. */ + @Test void testLogFuncByConvert() { +final SqlOperatorFixture f0 = fixture(); +f0.setFor(SqlLibraryOperators.LOG, VmName.EXPAND); +final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY); +f.checkScalarApprox("log(2.0/3, 2)", "DOUBLE NOT NULL", Review Comment: Hello, thank you very much for your suggestion. Regarding negative test, I think of the following case - log10(-1): When the parameter in log10 is a negative number - - log10(null): When the parameters in log10 are empty - - log10(-`Infinity`): When the parameter in log10 is -`Infinity` - - log10(0): When the parameter in log10 is 0 I tested based on mysql. Only when log(0) and log10(-1), calcite cannot match the results in mysql. In mysql, both of them return NULL. When log10(0), calcite returns -`Infinity. `log10(-1) returns NaN ![test2](https://github.com/apache/calcite/assets/77189278/c29a69b6-8c4e-4d94-b7c3-148da99f3243) -- 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
Re: [PR] [CALCITE-6224] Add LOG2 function (enabled in Mysql, Spark library) [calcite]
caicancai commented on code in PR #3648: URL: https://github.com/apache/calcite/pull/3648#discussion_r1479917763 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6215,6 +6215,71 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { f.checkNull("log(10, cast(null as real))"); } + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6224;>[CALCITE-6224] + * Add LOG@ function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +final Consumer consumer = f -> { + f.setFor(SqlLibraryOperators.LOG2); + f.checkScalarApprox("log2(2)", "DOUBLE NOT NULL", + isWithin(1.0, 0.01)); + f.checkScalarApprox("log2(4)", "DOUBLE NOT NULL", + isWithin(2.0, 0.01)); + f.checkScalarApprox("log2(65536)", "DOUBLE NOT NULL", + isWithin(16.0, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(2/3)", "DOUBLE NOT NULL", + "-Infinity"); + f.checkScalarApprox("log2(2.2)", "DOUBLE NOT NULL", + "1.1375035237499351"); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + "-1.0"); + f.checkScalarApprox("log2(3)", "DOUBLE NOT NULL", + isWithin(1.5849625007211563, 0.01)); + f.checkNull("log2(cast(null as real))"); +}; +f0.forEachLibrary(list(SqlLibrary.MYSQL, SqlLibrary.SPARK), consumer); + } + + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6232;>[CALCITE-6232] + * Using fractions in LOG function does not return correct results. */ + @Test void testLogFuncByConvert() { +final SqlOperatorFixture f0 = fixture(); +f0.setFor(SqlLibraryOperators.LOG, VmName.EXPAND); +final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY); +f.checkScalarApprox("log(2.0/3, 2)", "DOUBLE NOT NULL", Review Comment: Hello, thank you very much for your suggestion. Regarding negative test, I think of the following case - log10(-1): When the parameter in log10 is a negative number - log10(null): When the parameters in log10 are empty - log10(-`Infinity`): When the parameter in log10 is -`Infinity` - log10(0): When the parameter in log10 is 0 I tested based on mysql. Only when log(0) and log10(-1), calcite cannot match the results in mysql. In mysql, both of them return NULL. When log10(0), calcite returns -`Infinity. `log10(-1) returns NaN ![2024-02-06 22-20-16屏幕截图](https://github.com/apache/calcite/assets/77189278/27b21670-5364-463c-b6dc-d750c46d7cd1) -- 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
Re: [PR] [CALCITE-6224] Add LOG2 function (enabled in Mysql, Spark library) [calcite]
caicancai commented on code in PR #3648: URL: https://github.com/apache/calcite/pull/3648#discussion_r1479917763 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6215,6 +6215,71 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { f.checkNull("log(10, cast(null as real))"); } + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6224;>[CALCITE-6224] + * Add LOG@ function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +final Consumer consumer = f -> { + f.setFor(SqlLibraryOperators.LOG2); + f.checkScalarApprox("log2(2)", "DOUBLE NOT NULL", + isWithin(1.0, 0.01)); + f.checkScalarApprox("log2(4)", "DOUBLE NOT NULL", + isWithin(2.0, 0.01)); + f.checkScalarApprox("log2(65536)", "DOUBLE NOT NULL", + isWithin(16.0, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(2/3)", "DOUBLE NOT NULL", + "-Infinity"); + f.checkScalarApprox("log2(2.2)", "DOUBLE NOT NULL", + "1.1375035237499351"); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + "-1.0"); + f.checkScalarApprox("log2(3)", "DOUBLE NOT NULL", + isWithin(1.5849625007211563, 0.01)); + f.checkNull("log2(cast(null as real))"); +}; +f0.forEachLibrary(list(SqlLibrary.MYSQL, SqlLibrary.SPARK), consumer); + } + + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6232;>[CALCITE-6232] + * Using fractions in LOG function does not return correct results. */ + @Test void testLogFuncByConvert() { +final SqlOperatorFixture f0 = fixture(); +f0.setFor(SqlLibraryOperators.LOG, VmName.EXPAND); +final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY); +f.checkScalarApprox("log(2.0/3, 2)", "DOUBLE NOT NULL", Review Comment: Hello, thank you very much for your suggestion. Regarding negative test, I think of the following case - log10(-1): When the parameter in log10 is a negative number - log10(null): When the parameters in log10 are empty - log10(-`Infinity`): When the parameter in log10 is -`Infinity` - log10(0): When the parameter in log10 is 0 I tested based on mysql. Only when log(0) and log10(-1), calcite cannot match the results in mysql. In mysql, both of them return NULL. When log10(0), calcite returns -`Infinity. `log10(-1) returns NaN ![test2](https://github.com/apache/calcite/assets/77189278/c29a69b6-8c4e-4d94-b7c3-148da99f3243) -- 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
Re: [PR] [CALCITE-6171] Support Gremlin Adapter [calcite]
kaori-seasons commented on PR #3606: URL: https://github.com/apache/calcite/pull/3606#issuecomment-1929168117 @JiajunBernoulli Hello, I have fixed possible errors related to ci according to calcite's documentation, but when I run ci, I found the following error. In fact, in the root file of gradle, I have added the gremlin module to module management. Since I am not familiar with gradle, can you please provide me with some guidance? ``` Could not determine the dependencies of task ':gremlin:forbiddenApisTest'. > Could not resolve all task dependencies for configuration ':gremlin:testCompileClasspath'. > Could not resolve project :core. Required by: project :gremlin > Project :gremlin declares a dependency from configuration ``` -- 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
Re: [PR] [CALCITE-6223] Add MAP_CONTAINS_KEY function (enabled in Spark library) [calcite]
caicancai commented on PR #3655: URL: https://github.com/apache/calcite/pull/3655#issuecomment-1929166323 Thank you for your review -- 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
Re: [PR] [CALCITE-6241] Enable a few existing functions to Spark library [calcite]
YiwenWu commented on PR #3669: URL: https://github.com/apache/calcite/pull/3669#issuecomment-1929148811 > This PR seems good to go. I would like the commit message (and jira summary) to read 'Enable a few...' not 'Add...'. > > And the body of the commit message should list the functions. done, updated the jira summary and commit message -- 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
Re: [PR] [CALCITE-6241] Enable a few existing functions to Spark library [calcite]
sonarcloud[bot] commented on PR #3669: URL: https://github.com/apache/calcite/pull/3669#issuecomment-1929117075 ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3669) **Quality Gate passed** Kudos, no new issues were introduced! [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite=3669=false=true) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3669=false=true) [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3669=new_coverage=list) [17.1% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3669=new_duplicated_lines_density=list) [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite=3669) -- 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
Re: [PR] [CALCITE-6241] Enable a few existing functions to Spark library [calcite]
sonarcloud[bot] commented on PR #3669: URL: https://github.com/apache/calcite/pull/3669#issuecomment-1929088609 ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3669) **Quality Gate passed** Kudos, no new issues were introduced! [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite=3669=false=true) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3669=false=true) [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3669=new_coverage=list) [17.1% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3669=new_duplicated_lines_density=list) [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite=3669) -- 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
Re: [PR] [CALCITE-6223] Add MAP_CONTAINS_KEY function (enabled in Spark library) [calcite]
sonarcloud[bot] commented on PR #3655: URL: https://github.com/apache/calcite/pull/3655#issuecomment-1929057627 ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_calcite=3655) **Quality Gate passed** The SonarCloud Quality Gate passed, but some issues were introduced. [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite=3655=false=true) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3655=false=true) [90.2% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3655=new_coverage=list) [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3655=new_duplicated_lines_density=list) [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite=3655) -- 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