Re: [PR] [CALCITE-6268] Support implementing custom JdbcSchema [calcite]
kramerul commented on PR #3692: URL: https://github.com/apache/calcite/pull/3692#issuecomment-1953649441 > BTW: until the reviews are completed, it is recommended to just add new commits, so reviewers can easily see the new changes. Then you can squash the commits into a single one. Thank you for the hint. -- 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 #3689: URL: https://github.com/apache/calcite/pull/3689#issuecomment-1953439302 ## [![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=3689) **Quality Gate passed** Issues ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite=3689=false=true) Measures ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3689=false=true) ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [91.3% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3689=new_coverage=list) ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3689=new_duplicated_lines_density=list) [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite=3689) -- 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 #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495195172 ## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ## @@ -2788,6 +2788,18 @@ public static double log(BigDecimal d0, BigDecimal d1) { return Math.log(d0.doubleValue()) / Math.log(d1.doubleValue()); } + /** SQL {@code LOG2(number)} function applied to double values. */ + public static double log2(double d0) { +return (Double.isInfinite(log(d0, 2)) && d0 == 0.0) ? Double.NaN : log(d0, 2); Review Comment: Because - infinity and + infinity are special cases in SQL and do not support parsing, so I added the condition here that d0 == 0. At present, only the log2 (0) test is controversial. -- 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-6032] Multilevel correlated query is failing in RelDecorrela… [calcite]
mihaibudiu commented on code in PR #3640: URL: https://github.com/apache/calcite/pull/3640#discussion_r1495188308 ## core/src/test/java/org/apache/calcite/test/enumerable/EnumerableCorrelateTest.java: ## @@ -142,10 +142,10 @@ class EnumerableCorrelateTest { tester(false, new HrSchema()) .query( "select empid, name from emps e where exists (select 1 from depts d where d.deptno=e.deptno)") -.explainContains("" -+ "EnumerableCalc(expr#0..5=[{inputs}], empid=[$t0], name=[$t2])\n" -+ " EnumerableCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{1}])\n" -+ "EnumerableTableScan(table=[[s, emps]])\n" +.explainContains("EnumerableCalc(expr#0..3=[{inputs}], empid=[$t0], name=[$t2])\n " Review Comment: Great, thank you, I was only looking at the last commit. -- 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-6032] Multilevel correlated query is failing in RelDecorrela… [calcite]
HanumathRao commented on code in PR #3640: URL: https://github.com/apache/calcite/pull/3640#discussion_r1495187202 ## core/src/test/java/org/apache/calcite/test/enumerable/EnumerableCorrelateTest.java: ## @@ -142,10 +142,10 @@ class EnumerableCorrelateTest { tester(false, new HrSchema()) .query( "select empid, name from emps e where exists (select 1 from depts d where d.deptno=e.deptno)") -.explainContains("" -+ "EnumerableCalc(expr#0..5=[{inputs}], empid=[$t0], name=[$t2])\n" -+ " EnumerableCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{1}])\n" -+ "EnumerableTableScan(table=[[s, emps]])\n" +.explainContains("EnumerableCalc(expr#0..3=[{inputs}], empid=[$t0], name=[$t2])\n " Review Comment: Sorry, I assumed that you have looked at the new test case added in JdbcTest (testMultiLevelDecorrelation). If there is no RelFieldTrimmer fix then this new testcase fails with same exception as reported in the JIRA. -- 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 #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495186737 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6222,6 +6222,49 @@ 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 LOG2 function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +f0.checkFails("^log2(4)^", +"No match found for function signature LOG2\\(\\)", false); +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.0/3)", "DOUBLE NOT NULL", + isWithin(-0.5849625007211561, 0.01)); + f.checkScalarApprox("log2(4.0/3)", "DOUBLE NOT NULL", + isWithin(0.4150374992788435, 0.01)); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + isWithin(-1.0, 0.01)); + f.checkScalarApprox("log2(cast(10e8 as double))", "DOUBLE NOT NULL", + isWithin(29.897352853986263, 0.01)); + f.checkScalarApprox("log2(cast(10e8 as float))", "DOUBLE NOT NULL", + isWithin(29.897352853986263, 0.01)); + f.checkScalarApprox("log2(1e+52)", "DOUBLE NOT NULL", Review Comment: I added all the negative tests I could think of. At present, the test results are consistent with mysql. -- 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 #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495183607 ## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ## @@ -2790,13 +2790,13 @@ public static double log(BigDecimal d0, BigDecimal d1) { /** SQL {@code LOG2(number)} function applied to double values. */ public static double log2(double d0) { -return (d0 == 0) ? Double.NaN : Math.log(d0) / Math.log(2); +return (Double.isInfinite(log(d0, 2))) ? Double.NaN : log(d0, 2); Review Comment: Thank you very much for answering my question so patiently -- 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]
mihaibudiu commented on code in PR #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495182033 ## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ## @@ -2790,13 +2790,13 @@ public static double log(BigDecimal d0, BigDecimal d1) { /** SQL {@code LOG2(number)} function applied to double values. */ public static double log2(double d0) { -return (d0 == 0) ? Double.NaN : Math.log(d0) / Math.log(2); +return (Double.isInfinite(log(d0, 2))) ? Double.NaN : log(d0, 2); Review Comment: you can try a very large value, such as 1e+52 https://dev.mysql.com/doc/refman/8.0/en/problems-with-float.html -- 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 #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495180029 ## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ## @@ -2790,13 +2790,13 @@ public static double log(BigDecimal d0, BigDecimal d1) { /** SQL {@code LOG2(number)} function applied to double values. */ public static double log2(double d0) { -return (d0 == 0) ? Double.NaN : Math.log(d0) / Math.log(2); +return (Double.isInfinite(log(d0, 2))) ? Double.NaN : log(d0, 2); Review Comment: Mysql seems to be unable to support the parsing of +Infinity and -Infinity. From a mathematical point of view, I am not sure whether this makes sense, but mysql obviously does not support it. Maybe we can only deal with 0 specifically. I tested +0.0 and - 0.0 returns 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-6032] Multilevel correlated query is failing in RelDecorrela… [calcite]
sonarcloud[bot] commented on PR #3640: URL: https://github.com/apache/calcite/pull/3640#issuecomment-1953398744 ## [![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=3640) **Quality Gate passed** Issues ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [8 New issues](https://sonarcloud.io/project/issues?id=apache_calcite=3640=false=true) Measures ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3640=false=true) ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [98.2% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3640=new_coverage=list) ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3640=new_duplicated_lines_density=list) [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite=3640) -- 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-6032] Multilevel correlated query is failing in RelDecorrela… [calcite]
mihaibudiu commented on code in PR #3640: URL: https://github.com/apache/calcite/pull/3640#discussion_r1495174211 ## core/src/test/java/org/apache/calcite/test/enumerable/EnumerableCorrelateTest.java: ## @@ -142,10 +142,10 @@ class EnumerableCorrelateTest { tester(false, new HrSchema()) .query( "select empid, name from emps e where exists (select 1 from depts d where d.deptno=e.deptno)") -.explainContains("" -+ "EnumerableCalc(expr#0..5=[{inputs}], empid=[$t0], name=[$t2])\n" -+ " EnumerableCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{1}])\n" -+ "EnumerableTableScan(table=[[s, emps]])\n" +.explainContains("EnumerableCalc(expr#0..3=[{inputs}], empid=[$t0], name=[$t2])\n " Review Comment: The second half of my question stands. If the RelFieldTrimmer was wrong, is there a test case where you can show the difference? -- 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-6032] Multilevel correlated query is failing in RelDecorrela… [calcite]
HanumathRao commented on code in PR #3640: URL: https://github.com/apache/calcite/pull/3640#discussion_r1495172973 ## core/src/test/java/org/apache/calcite/test/enumerable/EnumerableCorrelateTest.java: ## @@ -142,10 +142,10 @@ class EnumerableCorrelateTest { tester(false, new HrSchema()) .query( "select empid, name from emps e where exists (select 1 from depts d where d.deptno=e.deptno)") -.explainContains("" -+ "EnumerableCalc(expr#0..5=[{inputs}], empid=[$t0], name=[$t2])\n" -+ " EnumerableCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{1}])\n" -+ "EnumerableTableScan(table=[[s, emps]])\n" +.explainContains("EnumerableCalc(expr#0..3=[{inputs}], empid=[$t0], name=[$t2])\n " Review Comment: There is no change in the plan, it was just an indentation fix. I have reverted it in the latest commit just to avoid any confusion. 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]
sonarcloud[bot] commented on PR #3689: URL: https://github.com/apache/calcite/pull/3689#issuecomment-1953391300 ## [![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=3689) **Quality Gate passed** Issues ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite=3689=false=true) Measures ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3689=false=true) ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [97.3% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3689=new_coverage=list) ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3689=new_duplicated_lines_density=list) [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite=3689) -- 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]
mihaibudiu commented on code in PR #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495170685 ## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ## @@ -2790,13 +2790,13 @@ public static double log(BigDecimal d0, BigDecimal d1) { /** SQL {@code LOG2(number)} function applied to double values. */ public static double log2(double d0) { -return (d0 == 0) ? Double.NaN : Math.log(d0) / Math.log(2); +return (Double.isInfinite(log(d0, 2))) ? Double.NaN : log(d0, 2); Review Comment: cast as double -- 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 #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495170001 ## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ## @@ -2790,13 +2790,13 @@ public static double log(BigDecimal d0, BigDecimal d1) { /** SQL {@code LOG2(number)} function applied to double values. */ public static double log2(double d0) { -return (d0 == 0) ? Double.NaN : Math.log(d0) / Math.log(2); +return (Double.isInfinite(log(d0, 2))) ? Double.NaN : log(d0, 2); Review Comment: log2(CAST "+Infinity' AS NULL), mysql does not support this type of parsing -- 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 #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495170001 ## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ## @@ -2790,13 +2790,13 @@ public static double log(BigDecimal d0, BigDecimal d1) { /** SQL {@code LOG2(number)} function applied to double values. */ public static double log2(double d0) { -return (d0 == 0) ? Double.NaN : Math.log(d0) / Math.log(2); +return (Double.isInfinite(log(d0, 2))) ? Double.NaN : log(d0, 2); Review Comment: log2(CAST "+Infinity' AS NULL), mysql does not support this type of parsing -- 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]
mihaibudiu commented on code in PR #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495168265 ## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ## @@ -2790,13 +2790,13 @@ public static double log(BigDecimal d0, BigDecimal d1) { /** SQL {@code LOG2(number)} function applied to double values. */ public static double log2(double d0) { -return (d0 == 0) ? Double.NaN : Math.log(d0) / Math.log(2); +return (Double.isInfinite(log(d0, 2))) ? Double.NaN : log(d0, 2); Review Comment: just make sure it matches MySQL on all corner cases -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-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 #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495167517 ## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ## @@ -2790,13 +2790,13 @@ public static double log(BigDecimal d0, BigDecimal d1) { /** SQL {@code LOG2(number)} function applied to double values. */ public static double log2(double d0) { -return (d0 == 0) ? Double.NaN : Math.log(d0) / Math.log(2); +return (Double.isInfinite(log(d0, 2))) ? Double.NaN : log(d0, 2); Review Comment: wait, Double.isInfinite(d0) && d0 < 0 ? I think you mean Double.isInfinite(log(d0, 2)) && d0.doubleValue() < 0.0 ## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ## @@ -2790,13 +2790,13 @@ public static double log(BigDecimal d0, BigDecimal d1) { /** SQL {@code LOG2(number)} function applied to double values. */ public static double log2(double d0) { -return (d0 == 0) ? Double.NaN : Math.log(d0) / Math.log(2); +return (Double.isInfinite(log(d0, 2))) ? Double.NaN : log(d0, 2); Review Comment: wait, Double.isInfinite(d0) && d0 < 0 ? I think you mean Double.isInfinite(log(d0, 2)) && d0.doubleValue() < 0.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 #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495167517 ## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ## @@ -2790,13 +2790,13 @@ public static double log(BigDecimal d0, BigDecimal d1) { /** SQL {@code LOG2(number)} function applied to double values. */ public static double log2(double d0) { -return (d0 == 0) ? Double.NaN : Math.log(d0) / Math.log(2); +return (Double.isInfinite(log(d0, 2))) ? Double.NaN : log(d0, 2); Review Comment: wait, Double.isInfinite(d0) && d0 < 0 , I think you mean Double.isInfinite(log(d0, 2)) && d0.doubleValue() < 0.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 #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495165517 ## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ## @@ -2790,13 +2790,13 @@ public static double log(BigDecimal d0, BigDecimal d1) { /** SQL {@code LOG2(number)} function applied to double values. */ public static double log2(double d0) { -return (d0 == 0) ? Double.NaN : Math.log(d0) / Math.log(2); +return (Double.isInfinite(log(d0, 2))) ? Double.NaN : log(d0, 2); Review Comment: Thank you -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-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]
mihaibudiu commented on code in PR #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495165126 ## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ## @@ -2790,13 +2790,13 @@ public static double log(BigDecimal d0, BigDecimal d1) { /** SQL {@code LOG2(number)} function applied to double values. */ public static double log2(double d0) { -return (d0 == 0) ? Double.NaN : Math.log(d0) / Math.log(2); +return (Double.isInfinite(log(d0, 2))) ? Double.NaN : log(d0, 2); Review Comment: `Double.isInfinite(d0) && d0 < 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 #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495164374 ## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ## @@ -2790,13 +2790,13 @@ public static double log(BigDecimal d0, BigDecimal d1) { /** SQL {@code LOG2(number)} function applied to double values. */ public static double log2(double d0) { -return (d0 == 0) ? Double.NaN : Math.log(d0) / Math.log(2); +return (Double.isInfinite(log(d0, 2))) ? Double.NaN : log(d0, 2); Review Comment: > that should work using < 0.0. The result of log2(2.0/3) is also less than 0.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 #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495163992 ## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ## @@ -2790,13 +2790,13 @@ public static double log(BigDecimal d0, BigDecimal d1) { /** SQL {@code LOG2(number)} function applied to double values. */ public static double log2(double d0) { -return (d0 == 0) ? Double.NaN : Math.log(d0) / Math.log(2); +return (Double.isInfinite(log(d0, 2))) ? Double.NaN : log(d0, 2); Review Comment: > I don't think this will work for the case of +infinity. You should add a test case for `log2(CAST "+Infinity' AS NULL)`. I expect that the result will be NaN, whereas you probably expect Infinity in that case. So you should also check that the infinity is negative here. Maybe I should check how mysql and spark work -- 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]
mihaibudiu commented on code in PR #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495160602 ## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ## @@ -2790,13 +2790,13 @@ public static double log(BigDecimal d0, BigDecimal d1) { /** SQL {@code LOG2(number)} function applied to double values. */ public static double log2(double d0) { -return (d0 == 0) ? Double.NaN : Math.log(d0) / Math.log(2); +return (Double.isInfinite(log(d0, 2))) ? Double.NaN : log(d0, 2); Review Comment: that should work using < 0.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]
mihaibudiu commented on code in PR #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495160430 ## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ## @@ -2790,13 +2790,13 @@ public static double log(BigDecimal d0, BigDecimal d1) { /** SQL {@code LOG2(number)} function applied to double values. */ public static double log2(double d0) { -return (d0 == 0) ? Double.NaN : Math.log(d0) / Math.log(2); +return (Double.isInfinite(log(d0, 2))) ? Double.NaN : log(d0, 2); Review Comment: I don't think this will work for the case of +infinity. You should add a test case for `log2(CAST "+Infinity' AS NULL)`. I expect that the result will be NaN, whereas you probably expect Infinity in that case. So you should also check that the infinity is negative 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-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 #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495159761 ## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ## @@ -2788,6 +2788,18 @@ public static double log(BigDecimal d0, BigDecimal d1) { return Math.log(d0.doubleValue()) / Math.log(d1.doubleValue()); } + /** SQL {@code LOG2(number)} function applied to double values. */ + public static double log2(double d0) { +return (d0 == 0) ? Double.NaN : Math.log(d0) / Math.log(2); + } + + /** SQL {@code LOG2(number)} function applied to + * BigDecimal and double values. */ + public static double log2(BigDecimal d0) { +return (d0.doubleValue() == 0) ? Double.NaN : Math.log(d0.doubleValue()) / Math.log(2); Review Comment: done,thank you. If I understand you correctly -- 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 #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495159761 ## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ## @@ -2788,6 +2788,18 @@ public static double log(BigDecimal d0, BigDecimal d1) { return Math.log(d0.doubleValue()) / Math.log(d1.doubleValue()); } + /** SQL {@code LOG2(number)} function applied to double values. */ + public static double log2(double d0) { +return (d0 == 0) ? Double.NaN : Math.log(d0) / Math.log(2); + } + + /** SQL {@code LOG2(number)} function applied to + * BigDecimal and double values. */ + public static double log2(BigDecimal d0) { +return (d0.doubleValue() == 0) ? Double.NaN : Math.log(d0.doubleValue()) / Math.log(2); Review Comment: done,thank you -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-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 #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495158019 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6222,6 +6222,41 @@ 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 LOG2 function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +f0.checkFails("^log2(4)^", +"No match found for function signature LOG2\\(\\)", false); +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.0/3)", "DOUBLE NOT NULL", + isWithin(-0.5849625007211561, 0.01)); + f.checkScalarApprox("log2(4.0/3)", "DOUBLE NOT NULL", + isWithin(0.4150374992788435, 0.01)); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + isWithin(-1.0, 0.01)); + f.checkScalarApprox("log2(cast(10e8 as double))", "DOUBLE NOT NULL", + isWithin(29.897352853986263, 0.01)); + f.checkScalarApprox("log2(cast(10e8 as float))", "DOUBLE NOT NULL", + isWithin(29.897352853986263, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(0)", "DOUBLE NOT NULL", + "NaN"); + f.checkNull("log2(cast(null as real))"); Review Comment: Uploading, sorry, testing locally -- 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 #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495158019 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6222,6 +6222,41 @@ 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 LOG2 function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +f0.checkFails("^log2(4)^", +"No match found for function signature LOG2\\(\\)", false); +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.0/3)", "DOUBLE NOT NULL", + isWithin(-0.5849625007211561, 0.01)); + f.checkScalarApprox("log2(4.0/3)", "DOUBLE NOT NULL", + isWithin(0.4150374992788435, 0.01)); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + isWithin(-1.0, 0.01)); + f.checkScalarApprox("log2(cast(10e8 as double))", "DOUBLE NOT NULL", + isWithin(29.897352853986263, 0.01)); + f.checkScalarApprox("log2(cast(10e8 as float))", "DOUBLE NOT NULL", + isWithin(29.897352853986263, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(0)", "DOUBLE NOT NULL", + "NaN"); + f.checkNull("log2(cast(null as real))"); Review Comment: Uploading, sorry -- 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]
mihaibudiu commented on code in PR #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495157340 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6222,6 +6222,41 @@ 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 LOG2 function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +f0.checkFails("^log2(4)^", +"No match found for function signature LOG2\\(\\)", false); +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.0/3)", "DOUBLE NOT NULL", + isWithin(-0.5849625007211561, 0.01)); + f.checkScalarApprox("log2(4.0/3)", "DOUBLE NOT NULL", + isWithin(0.4150374992788435, 0.01)); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + isWithin(-1.0, 0.01)); + f.checkScalarApprox("log2(cast(10e8 as double))", "DOUBLE NOT NULL", + isWithin(29.897352853986263, 0.01)); + f.checkScalarApprox("log2(cast(10e8 as float))", "DOUBLE NOT NULL", + isWithin(29.897352853986263, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(0)", "DOUBLE NOT NULL", + "NaN"); + f.checkNull("log2(cast(null as real))"); Review Comment: done perhaps, but I don't see a new commit yet -- 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 #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495156852 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6222,6 +6222,41 @@ 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 LOG2 function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +f0.checkFails("^log2(4)^", +"No match found for function signature LOG2\\(\\)", false); +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.0/3)", "DOUBLE NOT NULL", + isWithin(-0.5849625007211561, 0.01)); + f.checkScalarApprox("log2(4.0/3)", "DOUBLE NOT NULL", + isWithin(0.4150374992788435, 0.01)); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + isWithin(-1.0, 0.01)); + f.checkScalarApprox("log2(cast(10e8 as double))", "DOUBLE NOT NULL", + isWithin(29.897352853986263, 0.01)); + f.checkScalarApprox("log2(cast(10e8 as float))", "DOUBLE NOT NULL", + isWithin(29.897352853986263, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(0)", "DOUBLE NOT NULL", + "NaN"); + f.checkNull("log2(cast(null as real))"); Review Comment: done, 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-6032] Multilevel correlated query is failing in RelDecorrela… [calcite]
mihaibudiu commented on code in PR #3640: URL: https://github.com/apache/calcite/pull/3640#discussion_r1495155596 ## core/src/test/java/org/apache/calcite/test/enumerable/EnumerableCorrelateTest.java: ## @@ -142,10 +142,10 @@ class EnumerableCorrelateTest { tester(false, new HrSchema()) .query( "select empid, name from emps e where exists (select 1 from depts d where d.deptno=e.deptno)") -.explainContains("" -+ "EnumerableCalc(expr#0..5=[{inputs}], empid=[$t0], name=[$t2])\n" -+ " EnumerableCorrelate(correlation=[$cor0], joinType=[inner], requiredColumns=[{1}])\n" -+ "EnumerableTableScan(table=[[s, emps]])\n" +.explainContains("EnumerableCalc(expr#0..3=[{inputs}], empid=[$t0], name=[$t2])\n " Review Comment: was the previous plan incorrect? If not, can you provide a test case for which the previous plan was incorrect, but it is now correct? -- 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-6273] Add sqrt negative test in SqlOperatorTest [calcite]
JiajunBernoulli merged PR #3695: URL: https://github.com/apache/calcite/pull/3695 -- 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-6273] Add sqrt negative test in SqlOperatorTest
This is an automated email from the ASF dual-hosted git repository. jiajunxie 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 31d66e797d [CALCITE-6273] Add sqrt negative test in SqlOperatorTest 31d66e797d is described below commit 31d66e797d3ca66d154262b15ee35876804df963 Author: caicancai <2356672...@qq.com> AuthorDate: Sun Feb 18 23:28:52 2024 +0800 [CALCITE-6273] Add sqrt negative test in SqlOperatorTest --- .../main/java/org/apache/calcite/test/SqlOperatorTest.java | 12 1 file changed, 12 insertions(+) diff --git a/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java b/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java index 2ff72a1697..12052c9a82 100644 --- a/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java +++ b/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java @@ -6110,6 +6110,18 @@ public class SqlOperatorTest { isWithin(1.4142d, 0.0001d)); f.checkScalarApprox("sqrt(cast(2 as decimal(2, 0)))", "DOUBLE NOT NULL", isWithin(1.4142d, 0.0001d)); +f.checkScalarApprox("sqrt(0)", "DOUBLE NOT NULL", +isWithin(0, 0.0001d)); +f.checkScalarApprox("sqrt(0.1)", "DOUBLE NOT NULL", +isWithin(0.31622776601683794, 0.0001d)); +f.checkScalarApprox("sqrt(2.0/3)", "DOUBLE NOT NULL", +isWithin(0.816496580927726, 0.0001d)); +f.checkScalarApprox("sqrt(cast(10e8 as integer))", "DOUBLE NOT NULL", +isWithin(31622.776601683792, 0.0001d)); +f.checkScalarApprox("sqrt(cast(10e8 as double))", "DOUBLE NOT NULL", +isWithin(31622.776601683792, 0.0001d)); +f.checkScalarApprox("sqrt(-1)", "DOUBLE NOT NULL", +"NaN"); f.checkNull("sqrt(cast(null as integer))"); f.checkNull("sqrt(cast(null as double))"); }
Re: [PR] [CALCITE-6224] Add LOG2 function (enabled in Mysql, Spark library) [calcite]
caicancai commented on code in PR #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1495152436 ## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ## @@ -2788,6 +2788,18 @@ public static double log(BigDecimal d0, BigDecimal d1) { return Math.log(d0.doubleValue()) / Math.log(d1.doubleValue()); } + /** SQL {@code LOG2(number)} function applied to double values. */ + public static double log2(double d0) { +return (d0 == 0) ? Double.NaN : Math.log(d0) / Math.log(2); Review Comment: Thank you, learned it -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
Re: [PR] [CALCITE-6260] Add already implemented functions in Spark library [calcite]
mihaibudiu commented on code in PR #3684: URL: https://github.com/apache/calcite/pull/3684#discussion_r1495018416 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -2259,6 +2272,27 @@ private static void checkConcatWithSeparatorInMSSQL(SqlOperatorFixture f) { f.checkString("concat_ws('', '', '', '')", "", "VARCHAR(0) NOT NULL"); } + private static void checkConcatWithSeparatorInSpark(SqlOperatorFixture f) { +f.setFor(SqlLibraryOperators.CONCAT_WS_SPARK); +f.checkString("concat_ws(',', 'a')", "a", "VARCHAR(1) NOT NULL"); +f.checkString("concat_ws(',', 'a', 'b', null, 'c')", "a,b,c", +"VARCHAR NOT NULL"); +f.checkString("concat_ws(',', cast('a' as varchar), cast('b' as varchar))", +"a,b", "VARCHAR NOT NULL"); +f.checkString("concat_ws(',', cast('a' as varchar(2)), cast('b' as varchar(1)))", +"a,b", "VARCHAR(4) NOT NULL"); +f.checkString("concat_ws(',', '', '', '')", ",,", "VARCHAR(2) NOT NULL"); +f.checkString("concat_ws(',', null, null, null)", "", "VARCHAR NOT NULL"); +// returns null if the separator is null +f.checkNull("concat_ws(null, 'a', 'b')"); +f.checkNull("concat_ws(null, null, null)"); +f.checkString("concat_ws(',')", "", "VARCHAR(0) NOT NULL"); +// if the separator is empty string, it's equivalent to CONCAT +f.checkString("concat_ws('', cast('a' as varchar(2)), cast('b' as varchar(1)))", +"ab", "VARCHAR(3) NOT NULL"); +f.checkString("concat_ws('', '', '', '')", "", "VARCHAR(0) NOT NULL"); Review Comment: the way you wrote the function description, it can accept a mix of multiple arrays and strings too. Can you either write tests for that case or fix the description? -- 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-6268] Support implementing custom JdbcSchema [calcite]
mihaibudiu commented on PR #3692: URL: https://github.com/apache/calcite/pull/3692#issuecomment-1953163472 BTW: until the reviews are completed, it is recommended to just add new commits, so reviewers can easily see the new changes. Then you can squash the commits into a single one. -- 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-6268] Support implementing custom JdbcSchema [calcite]
mihaibudiu commented on code in PR #3692: URL: https://github.com/apache/calcite/pull/3692#discussion_r1494969469 ## core/src/test/java/org/apache/calcite/test/JdbcTest.java: ## @@ -241,6 +245,55 @@ public class JdbcTest { + "(8,1,4))\n" + " as t(rn,val,expected)"; + public static final String FOODMART_SCOTT_CUSTOM_MODEL = "{\n" + + " version: '1.0',\n" + + " schemas: [\n" + + " {\n" + + " type: 'custom',\n" + + " factory: '" + + JdbcCustomSchemaFactory.class.getName() + + "',\n" + + " name: 'SCOTT'\n" + + " }\n" + + " ]\n" + + "}"; + + + /** + * Tests class fro custom JDBC schema. Review Comment: typo ## core/src/test/java/org/apache/calcite/test/JdbcTest.java: ## @@ -241,6 +245,55 @@ public class JdbcTest { + "(8,1,4))\n" + " as t(rn,val,expected)"; + public static final String FOODMART_SCOTT_CUSTOM_MODEL = "{\n" + + " version: '1.0',\n" + + " schemas: [\n" + + " {\n" + + " type: 'custom',\n" + + " factory: '" + + JdbcCustomSchemaFactory.class.getName() + + "',\n" + + " name: 'SCOTT'\n" + + " }\n" + + " ]\n" + + "}"; + + + /** + * Tests class fro custom JDBC schema. + */ + public static class JdbcCustomSchema extends DelegatingSchema implements Wrapper { + +public JdbcCustomSchema(SchemaPlus parentSchema, String name) { + super(JdbcSchema.create(parentSchema, name, getDataSource(), SCOTT.catalog, SCOTT.schema)); +} + +private static DataSource getDataSource() { + return JdbcSchema.dataSource(SCOTT.url, SCOTT.driver, SCOTT.username, SCOTT.password); +} + +@Override public Schema snapshot(SchemaVersion version) { + return this; +} + +@Override public @Nullable T unwrap(Class clazz) { + if (schema instanceof Wrapper) { +return ((Wrapper) schema).unwrap(clazz); + } + return null; +} + } + + /** + * Tests class fro custom JDBC schema factory. Review Comment: same typo. ## core/src/test/java/org/apache/calcite/test/JdbcTest.java: ## @@ -241,6 +245,55 @@ public class JdbcTest { + "(8,1,4))\n" + " as t(rn,val,expected)"; + public static final String FOODMART_SCOTT_CUSTOM_MODEL = "{\n" + + " version: '1.0',\n" + + " schemas: [\n" + + " {\n" + + " type: 'custom',\n" + + " factory: '" + + JdbcCustomSchemaFactory.class.getName() + + "',\n" + + " name: 'SCOTT'\n" + + " }\n" + + " ]\n" + + "}"; + + + /** + * Tests class fro custom JDBC schema. Review Comment: The question I still have: how are users supposed to use the new capabilities you are enabling? Can you add a longer comment giving a recipe for the problem you are solving and how people are supposed to solve it using these tools - pointing them to this example. -- 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]
mihaibudiu commented on code in PR #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1494967077 ## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ## @@ -2788,6 +2788,18 @@ public static double log(BigDecimal d0, BigDecimal d1) { return Math.log(d0.doubleValue()) / Math.log(d1.doubleValue()); } + /** SQL {@code LOG2(number)} function applied to double values. */ + public static double log2(double d0) { +return (d0 == 0) ? Double.NaN : Math.log(d0) / Math.log(2); + } + + /** SQL {@code LOG2(number)} function applied to + * BigDecimal and double values. */ + public static double log2(BigDecimal d0) { +return (d0.doubleValue() == 0) ? Double.NaN : Math.log(d0.doubleValue()) / Math.log(2); Review Comment: just call the other function. ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6222,6 +6222,41 @@ 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 LOG2 function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +f0.checkFails("^log2(4)^", +"No match found for function signature LOG2\\(\\)", false); +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.0/3)", "DOUBLE NOT NULL", + isWithin(-0.5849625007211561, 0.01)); + f.checkScalarApprox("log2(4.0/3)", "DOUBLE NOT NULL", + isWithin(0.4150374992788435, 0.01)); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + isWithin(-1.0, 0.01)); + f.checkScalarApprox("log2(cast(10e8 as double))", "DOUBLE NOT NULL", + isWithin(29.897352853986263, 0.01)); + f.checkScalarApprox("log2(cast(10e8 as float))", "DOUBLE NOT NULL", + isWithin(29.897352853986263, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkScalarApprox("log2(0)", "DOUBLE NOT NULL", + "NaN"); + f.checkNull("log2(cast(null as real))"); Review Comment: how about a test with just NULL, without the cast? that should work. ## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ## @@ -2788,6 +2788,18 @@ public static double log(BigDecimal d0, BigDecimal d1) { return Math.log(d0.doubleValue()) / Math.log(d1.doubleValue()); } + /** SQL {@code LOG2(number)} function applied to double values. */ + public static double log2(double d0) { +return (d0 == 0) ? Double.NaN : Math.log(d0) / Math.log(2); Review Comment: In general testing for equality FP values does not work. There are also two kinds of zeros in FP, +0 and -0. If the result from Math.log(0) is -Infinity, the more robust way to do this is to actually compute the log and check when the result is the negative infinity. -- 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-6260] Add already implemented functions in Spark library [calcite]
caicancai commented on code in PR #3684: URL: https://github.com/apache/calcite/pull/3684#discussion_r1494627130 ## site/_docs/reference.md: ## @@ -2700,12 +2700,14 @@ In the following: | s | BIT_GET(value, position) | Returns the bit (0 or 1) value at the specified *position* of numeric *value*. The positions are numbered from right to left, starting at zero. The *position* argument cannot be negative | b | CEIL(value)| Similar to standard `CEIL(value)` except if *value* is an integer type, the return type is a double | m s | CHAR(integer)| Returns the character whose ASCII code is *integer* % 256, or null if *integer* 0 +| s | CHR(integer) | Returns the character whose ASCII code is *integer* % 256, or null if *integer* 0 Review Comment: @JiajunBernoulli @YiwenWu If some functions of spark are different from other sql engines, I do not recommend putting them in this jira, as this can easily cause confusion. We need to open a new jira to discuss it, what is the difference and what negative tests need to be added? -- 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-6249] RelNode::estimatedRowCount should not be used in computeSelfCost [calcite]
rubenada commented on PR #3674: URL: https://github.com/apache/calcite/pull/3674#issuecomment-1952221395 That would be great @caicancai . Apart from this PR, you can also take a look at https://github.com/apache/calcite/commit/f7069cc5245c22f816c565669f52b4f30b046f4d , which was a similar (more localized) change, which included a unit test. -- 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-6249] RelNode::estimatedRowCount should not be used in computeSelfCost [calcite]
caicancai commented on PR #3674: URL: https://github.com/apache/calcite/pull/3674#issuecomment-1952211163 @rubenada @tanclary Maybe I can try reading this pr change to see if there are any tests that need to be added, I agree with clary to some extent -- 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 #3689: URL: https://github.com/apache/calcite/pull/3689#issuecomment-1952089788 ## [![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=3689) **Quality Gate passed** Issues ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite=3689=false=true) Measures ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3689=false=true) ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [97.2% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3689=new_coverage=list) ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3689=new_duplicated_lines_density=list) [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite=3689) -- 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-6268] Support implementing custom JdbcSchema [calcite]
kramerul commented on PR #3692: URL: https://github.com/apache/calcite/pull/3692#issuecomment-1952056421 Hi @mihaibudiu, I added a unit test for this feature. -- 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 #3689: URL: https://github.com/apache/calcite/pull/3689#issuecomment-1952051401 ## [![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=3689) **Quality Gate passed** Issues ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2 New issues](https://sonarcloud.io/project/issues?id=apache_calcite=3689=false=true) Measures ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3689=false=true) ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [94.6% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3689=new_coverage=list) ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3689=new_duplicated_lines_density=list) [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite=3689) -- 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 PR #3689: URL: https://github.com/apache/calcite/pull/3689#issuecomment-1952002300 @mihaibudiu @tanclary I added a function to log2 in Sqlfunctions, I can't think of a better solution, if you have, please let me know, I would be very grateful -- 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 #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1494221853 ## core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java: ## @@ -2149,6 +2149,18 @@ private static RelDataType deriveTypeMapFromEntries(SqlOperatorBinding opBinding OperandTypes.NUMERIC_OPTIONAL_NUMERIC, SqlFunctionCategory.NUMERIC); + /** The "LOG2(value)" function. + * + * @see SqlStdOperatorTable#LN + * @see SqlStdOperatorTable#LOG10 + */ + @LibraryOperator(libraries = {MYSQL, SPARK}) + public static final SqlFunction LOG2 = + SqlBasicFunction.create("LOG2", + ReturnTypes.DOUBLE_NULLABLE, + OperandTypes.NUMERIC, Review Comment: I don't think there is any problem in keeping it the same as log10. I added test to explain it -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-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 #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1494220246 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6218,10 +6226,43 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { isWithin(9.0, 0.01)); f.checkScalarApprox("log(cast(10e-3 as real), 10)", "DOUBLE NOT NULL", isWithin(-2.0, 0.01)); +f.checkScalarApprox("log(2.0/3, 100)", "DOUBLE NOT NULL", +isWithin(-0.08804562952784059, 0.01)); +f.checkScalarApprox("log(0.5, 2)", "DOUBLE NOT NULL", +isWithin(-1.0, 0.01)); Review Comment: Regarding log10 and log functions, I will not fix them in this jira, because the jira is only for log2 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-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 #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1494218639 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6218,10 +6226,43 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { isWithin(9.0, 0.01)); f.checkScalarApprox("log(cast(10e-3 as real), 10)", "DOUBLE NOT NULL", isWithin(-2.0, 0.01)); +f.checkScalarApprox("log(2.0/3, 100)", "DOUBLE NOT NULL", +isWithin(-0.08804562952784059, 0.01)); +f.checkScalarApprox("log(0.5, 2)", "DOUBLE NOT NULL", +isWithin(-1.0, 0.01)); f.checkNull("log(cast(null as real), 10)"); f.checkNull("log(10, cast(null as real))"); } + + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6224;>[CALCITE-6224] + * Add LOG2 function (enabled in MYSQL, Spark library). */ + @Test void testLog2Func() { +final SqlOperatorFixture f0 = fixture(); +f0.checkFails("^log2(4)^", +"No match found for function signature LOG2\\(\\)", false); +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.0/3)", "DOUBLE NOT NULL", + isWithin(-0.5849625007211561, 0.01)); + f.checkScalarApprox("log2(4.0/3)", "DOUBLE NOT NULL", + isWithin(0.4150374992788435, 0.01)); + f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL", + isWithin(-1.0, 0.01)); + f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL", + "NaN"); + f.checkNull("log2(cast(null as real))"); 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
Re: [PR] [CALCITE-6273] Add sqrt negative test in SqlOperatorTest [calcite]
rubenada commented on PR #3695: URL: https://github.com/apache/calcite/pull/3695#issuecomment-1951954908 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-unsubscr...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
(calcite) branch main updated: [CALCITE-6249] RelNode::estimatedRowCount should not be used in computeSelfCost
This is an automated email from the ASF dual-hosted git repository. rubenql 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 a19a954738 [CALCITE-6249] RelNode::estimatedRowCount should not be used in computeSelfCost a19a954738 is described below commit a19a954738e3405f621843a9df71e51002e1609b Author: Ulrich Kramer AuthorDate: Wed Feb 7 08:07:36 2024 +0100 [CALCITE-6249] RelNode::estimatedRowCount should not be used in computeSelfCost --- .../calcite/adapter/enumerable/EnumerableBatchNestedLoopJoin.java | 4 ++-- .../org/apache/calcite/adapter/enumerable/EnumerableHashJoin.java | 4 ++-- .../org/apache/calcite/adapter/enumerable/EnumerableMergeJoin.java| 4 ++-- .../apache/calcite/adapter/enumerable/EnumerableNestedLoopJoin.java | 4 ++-- core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcRules.java | 4 ++-- core/src/main/java/org/apache/calcite/rel/core/Correlate.java | 4 ++-- core/src/main/java/org/apache/calcite/rel/core/TableScan.java | 2 +- .../java/org/apache/calcite/rel/rules/AggregateStarTableRule.java | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableBatchNestedLoopJoin.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableBatchNestedLoopJoin.java index 94ef9c3213..11a3620c8c 100644 --- a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableBatchNestedLoopJoin.java +++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableBatchNestedLoopJoin.java @@ -124,8 +124,8 @@ public class EnumerableBatchNestedLoopJoin extends Join implements EnumerableRel final RelMetadataQuery mq) { double rowCount = mq.getRowCount(this); -final double rightRowCount = right.estimateRowCount(mq); -final double leftRowCount = left.estimateRowCount(mq); +final double rightRowCount = mq.getRowCount(right); +final double leftRowCount = mq.getRowCount(left); if (Double.isInfinite(leftRowCount) || Double.isInfinite(rightRowCount)) { return planner.getCostFactory().makeInfiniteCost(); } diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableHashJoin.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableHashJoin.java index cfe44da75d..8bd9ffbf08 100644 --- a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableHashJoin.java +++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableHashJoin.java @@ -149,8 +149,8 @@ public class EnumerableHashJoin extends Join implements EnumerableRel { // Cheaper if the smaller number of rows is coming from the LHS. // Model this by adding L log L to the cost. -final double rightRowCount = right.estimateRowCount(mq); -final double leftRowCount = left.estimateRowCount(mq); +final double rightRowCount = mq.getRowCount(right); +final double leftRowCount = mq.getRowCount(left); if (Double.isInfinite(leftRowCount)) { rowCount = leftRowCount; } else { diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableMergeJoin.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableMergeJoin.java index 3f42e065c8..97eae019d3 100644 --- a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableMergeJoin.java +++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableMergeJoin.java @@ -424,8 +424,8 @@ public class EnumerableMergeJoin extends Join implements EnumerableRel { // We assume that the inputs are sorted. The price of sorting them has // already been paid. The cost of the join is therefore proportional to the // input and output size. -final double rightRowCount = right.estimateRowCount(mq); -final double leftRowCount = left.estimateRowCount(mq); +final double rightRowCount = mq.getRowCount(right); +final double leftRowCount = mq.getRowCount(left); final double rowCount = mq.getRowCount(this); final double d = leftRowCount + rightRowCount + rowCount; return planner.getCostFactory().makeCost(d, 0, 0); diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableNestedLoopJoin.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableNestedLoopJoin.java index 6b1bf40cf7..de539ad574 100644 --- a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableNestedLoopJoin.java +++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableNestedLoopJoin.java @@ -108,8 +108,8 @@ public class EnumerableNestedLoopJoin extends Join implements EnumerableRel { } } -final double rightRowCount = right.estimateRowCount(mq); -final double leftRowCount = left.estimateRowCount(mq); +final double rightRowCount = mq.getRowCount(right); +
Re: [PR] [CALCITE-6249] RelNode::estimatedRowCount should not be used in computeSelfCost [calcite]
rubenada merged PR #3674: URL: https://github.com/apache/calcite/pull/3674 -- 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-6268] Support implementing custom JdbcSchema [calcite]
sonarcloud[bot] commented on PR #3692: URL: https://github.com/apache/calcite/pull/3692#issuecomment-1951929853 ## [![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=3692) **Quality Gate passed** Issues ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite=3692=false=true) Measures ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite=3692=false=true) ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [59.1% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3692=new_coverage=list) ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite=3692=new_duplicated_lines_density=list) [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite=3692) -- 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