Re: [PR] [CALCITE-6314] Add RANDOM function (enabled in Postgres library) [calcite]
tanclary merged PR #3720: URL: https://github.com/apache/calcite/pull/3720 -- 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-6314] Add RANDOM function (enabled in Postgres library) [calcite]
jduo commented on PR #3720: URL: https://github.com/apache/calcite/pull/3720#issuecomment-1996068360 > Looks like some merge conflicts? Updated the PR. It's introduced from merging CALCITE-6278. I expect we'll see more of this since we have a few devs working on adding functions now. -- 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-6314] Add RANDOM function (enabled in Postgres library) [calcite]
sonarcloud[bot] commented on PR #3720: URL: https://github.com/apache/calcite/pull/3720#issuecomment-1986515616 ## [![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&pullRequest=3720) **Quality Gate passed** Issues ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [4 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3720&resolved=false&inNewCodePeriod=true) ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3720&metric=new_accepted_issues&view=list) 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&pullRequest=3720&resolved=false&inNewCodePeriod=true) ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3720&metric=new_coverage&view=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&pullRequest=3720&metric=new_duplicated_lines_density&view=list) [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3720) -- 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-6314] Add RANDOM function (enabled in Postgres library) [calcite]
jduo commented on code in PR #3720: URL: https://github.com/apache/calcite/pull/3720#discussion_r1518364276 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6307,6 +6307,22 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { } } + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6314";>[CALCITE-6314] + * Add RANDOM function (enabled in Postgres library). */ + @Test void testRandomFunc() { +final SqlOperatorFixture f = fixture(); +f.setFor(SqlLibraryOperators.RANDOM, VmName.EXPAND); +f.checkFails("^random^", "Column 'RANDOM' not found in any table", false); +Consumer test = fixture -> { Review Comment: Sure, I've renamed test to consumer. -- 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-6314] Add RANDOM function (enabled in Postgres library) [calcite]
tanclary commented on code in PR #3720: URL: https://github.com/apache/calcite/pull/3720#discussion_r1518338635 ## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ## @@ -6307,6 +6307,22 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { } } + /** Test case for + * https://issues.apache.org/jira/browse/CALCITE-6314";>[CALCITE-6314] + * Add RANDOM function (enabled in Postgres library). */ + @Test void testRandomFunc() { +final SqlOperatorFixture f = fixture(); +f.setFor(SqlLibraryOperators.RANDOM, VmName.EXPAND); +f.checkFails("^random^", "Column 'RANDOM' not found in any table", false); +Consumer test = fixture -> { Review Comment: sorry this looks good but can we just call this `consumer` to fit the pattern of other tests? `test` doesn't tell us much -- 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-6314] Add RANDOM function (enabled in Postgres library) [calcite]
jduo commented on code in PR #3720: URL: https://github.com/apache/calcite/pull/3720#discussion_r1518315683 ## core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java: ## @@ -2257,4 +2258,16 @@ private static RelDataType deriveTypeMapFromEntries(SqlOperatorBinding opBinding @LibraryOperator(libraries = {SPARK}) public static final SqlFunction GETBIT = BIT_GET.withName("GETBIT"); + + /** The RANDOM() function. Equivalent to RAND(). */ + @LibraryOperator(libraries = {POSTGRESQL}) + public static final SqlFunction RANDOM = new SqlRandFunction() { Review Comment: Yes, I wound up adding more with*() functions to SqlBasicFunction for setting dynamic and the OperandTypeValidator and made both RAND() and RANDOM() instances of 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-6314] Add RANDOM function (enabled in Postgres library) [calcite]
tanclary commented on code in PR #3720: URL: https://github.com/apache/calcite/pull/3720#discussion_r1518308327 ## core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java: ## @@ -2257,4 +2258,16 @@ private static RelDataType deriveTypeMapFromEntries(SqlOperatorBinding opBinding @LibraryOperator(libraries = {SPARK}) public static final SqlFunction GETBIT = BIT_GET.withName("GETBIT"); + + /** The RANDOM() function. Equivalent to RAND(). */ + @LibraryOperator(libraries = {POSTGRESQL}) + public static final SqlFunction RANDOM = new SqlRandFunction() { Review Comment: the constructor is private because you're meant to use `.create()` -- 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-6314] Add RANDOM function (enabled in Postgres library) [calcite]
sonarcloud[bot] commented on PR #3720: URL: https://github.com/apache/calcite/pull/3720#issuecomment-1986290994 ## [![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&pullRequest=3720) **Quality Gate passed** Issues ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [4 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3720&resolved=false&inNewCodePeriod=true) ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3720&metric=new_accepted_issues&view=list) 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&pullRequest=3720&resolved=false&inNewCodePeriod=true) ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3720&metric=new_coverage&view=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&pullRequest=3720&metric=new_duplicated_lines_density&view=list) [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3720) -- 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-6314] Add RANDOM function (enabled in Postgres library) [calcite]
jduo commented on code in PR #3720: URL: https://github.com/apache/calcite/pull/3720#discussion_r1518187566 ## core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java: ## @@ -2257,4 +2258,16 @@ private static RelDataType deriveTypeMapFromEntries(SqlOperatorBinding opBinding @LibraryOperator(libraries = {SPARK}) public static final SqlFunction GETBIT = BIT_GET.withName("GETBIT"); + + /** The RANDOM() function. Equivalent to RAND(). */ + @LibraryOperator(libraries = {POSTGRESQL}) + public static final SqlFunction RANDOM = new SqlRandFunction() { 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-6314] Add RANDOM function (enabled in Postgres library) [calcite]
jduo commented on code in PR #3720: URL: https://github.com/apache/calcite/pull/3720#discussion_r1518171277 ## core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java: ## @@ -2257,4 +2258,16 @@ private static RelDataType deriveTypeMapFromEntries(SqlOperatorBinding opBinding @LibraryOperator(libraries = {SPARK}) public static final SqlFunction GETBIT = BIT_GET.withName("GETBIT"); + + /** The RANDOM() function. Equivalent to RAND(). */ + @LibraryOperator(libraries = {POSTGRESQL}) + public static final SqlFunction RANDOM = new SqlRandFunction() { Review Comment: SqlBasicFunction has a private constructor. I'll look into making RAND be an instance of SqlBasicFunction then RANDOM being a variant instead. -- 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-6314] Add RANDOM function (enabled in Postgres library) [calcite]
tanclary commented on code in PR #3720: URL: https://github.com/apache/calcite/pull/3720#discussion_r1518005426 ## core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java: ## @@ -2257,4 +2258,16 @@ private static RelDataType deriveTypeMapFromEntries(SqlOperatorBinding opBinding @LibraryOperator(libraries = {SPARK}) public static final SqlFunction GETBIT = BIT_GET.withName("GETBIT"); + + /** The RANDOM() function. Equivalent to RAND(). */ + @LibraryOperator(libraries = {POSTGRESQL}) + public static final SqlFunction RANDOM = new SqlRandFunction() { Review Comment: can't you make SqlRandFunction extend SqlBasicfunction ## site/_docs/reference.md: ## @@ -2813,6 +2813,7 @@ In the following: | b | PARSE_TIMESTAMP(format, string[, timeZone])| Uses format specified by *format* to convert *string* representation of timestamp to a TIMESTAMP WITH LOCAL TIME ZONE value in *timeZone* | h s | PARSE_URL(urlString, partToExtract [, keyToExtract] ) | Returns the specified *partToExtract* from the *urlString*. Valid values for *partToExtract* include HOST, PATH, QUERY, REF, PROTOCOL, AUTHORITY, FILE, and USERINFO. *keyToExtract* specifies which query to extract | b s | POW(numeric1, numeric2) | Returns *numeric1* raised to the power *numeric2* +| p | RANDOM() | Generates a random double between 0 and 1 inclusive Review Comment: ah sorry didn't see there's a difference, this is fine -- 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-6314] Add RANDOM function (enabled in Postgres library) [calcite]
sonarcloud[bot] commented on PR #3720: URL: https://github.com/apache/calcite/pull/3720#issuecomment-1985646911 ## [![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&pullRequest=3720) **Quality Gate passed** Issues ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [4 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3720&resolved=false&inNewCodePeriod=true) ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3720&metric=new_accepted_issues&view=list) 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&pullRequest=3720&resolved=false&inNewCodePeriod=true) ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3720&metric=new_coverage&view=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&pullRequest=3720&metric=new_duplicated_lines_density&view=list) [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3720) -- 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