You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by "snuyanzin (via GitHub)" <gi...@apache.org> on 2023/12/21 23:29:11 UTC
[PR] [CALCITE-6172] PoC for parameterized tests [calcite]
snuyanzin opened a new pull request, #3590:
URL: https://github.com/apache/calcite/pull/3590
(no comment)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "julianhyde (via GitHub)" <gi...@apache.org>.
julianhyde commented on code in PR #3590:
URL: https://github.com/apache/calcite/pull/3590#discussion_r1434594471
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -13686,6 +13673,31 @@ void testCastTruncates(CastType castType, SqlOperatorFixture f) {
}
}
+ static class AliasInfo {
+ private final SqlFunction function;
+ private final String alias;
+ private final SqlLibrary[] libraries;
Review Comment:
Constructor parameter should be varargs, not array.
`libraries` field should be immutable list, not array.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "tanclary (via GitHub)" <gi...@apache.org>.
tanclary commented on PR #3590:
URL: https://github.com/apache/calcite/pull/3590#issuecomment-1888065444
> This has developed a conflict, can you please fix it and I will merge.
This is just a PoC it can be closed, I merged the actual impl
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "tanclary (via GitHub)" <gi...@apache.org>.
tanclary commented on code in PR #3590:
URL: https://github.com/apache/calcite/pull/3590#discussion_r1435264996
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -8897,56 +8898,44 @@ private void testCurrentDateFunc(Pair<String, Hook.Closeable> pair) {
f0.forEachLibrary(list(SqlLibrary.BIG_QUERY, SqlLibrary.ORACLE), consumer);
}
- @Test void testStartsWithFunction() {
+ /** Tests the {@code STARTS_WITH} and {@code STARTSWITH} operator. */
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("startsWithAliases")
+ void testStartsWithFunction2(FunctionAlias functionAlias) {
final SqlOperatorFixture f0 = fixture();
- f0.setFor(SqlLibraryOperators.STARTS_WITH);
+ final SqlFunction function = functionAlias.function;
+ f0.setFor(function);
+ final String alias = functionAlias.alias;
final Consumer<SqlOperatorFixture> consumer = f -> {
- f.checkBoolean("starts_with('12345', '123')", true);
- f.checkBoolean("starts_with('12345', '1243')", false);
- f.checkBoolean("starts_with(x'11', x'11')", true);
- f.checkBoolean("starts_with(x'112211', x'33')", false);
- f.checkFails("^starts_with('aabbcc', x'aa')^",
- "Cannot apply 'STARTS_WITH' to arguments of type "
- + "'STARTS_WITH\\(<CHAR\\(6\\)>, <BINARY\\(1\\)>\\)'\\. Supported "
- + "form\\(s\\): 'STARTS_WITH\\(<STRING>, <STRING>\\)'",
+ f.checkBoolean(alias + "('12345', '123')", true);
+ f.checkBoolean(alias + "('12345', '1243')", false);
+ f.checkBoolean(alias + "(x'11', x'11')", true);
+ f.checkBoolean(alias + "(x'112211', x'33')", false);
+ f.checkFails("^" + alias + "('aabbcc', x'aa')^",
+ "Cannot apply '" + function.getName() + "' to arguments of type "
+ + "'" + function.getName() + "\\(<CHAR\\(6\\)>, <BINARY\\(1\\)>\\)'\\. Supported "
+ + "form\\(s\\): '" + function.getName() + "\\(<STRING>, <STRING>\\)'",
false);
- f.checkNull("starts_with(null, null)");
- f.checkNull("starts_with('12345', null)");
- f.checkNull("starts_with(null, '123')");
- f.checkBoolean("starts_with('', '123')", false);
- f.checkBoolean("starts_with('', '')", true);
- f.checkNull("starts_with(x'aa', null)");
- f.checkNull("starts_with(null, x'aa')");
- f.checkBoolean("starts_with(x'1234', x'')", true);
- f.checkBoolean("starts_with(x'', x'123456')", false);
- f.checkBoolean("starts_with(x'', x'')", true);
+ f.checkNull(alias + "(null, null)");
+ f.checkNull(alias + "('12345', null)");
+ f.checkNull(alias + "(null, '123')");
+ f.checkBoolean(alias + "('', '123')", false);
+ f.checkBoolean(alias + "('', '')", true);
+ f.checkNull(alias + "(x'aa', null)");
+ f.checkNull(alias + "(null, x'aa')");
+ f.checkBoolean(alias + "(x'1234', x'')", true);
+ f.checkBoolean(alias + "(x'', x'123456')", false);
+ f.checkBoolean(alias + "(x'', x'')", true);
};
- f0.forEachLibrary(list(SqlLibrary.BIG_QUERY, SqlLibrary.POSTGRESQL), consumer);
+ f0.forEachLibrary(list(functionAlias.libraries), consumer);
}
- /** Tests for Snowflake's {@code STARTSWITH} function. */
- @Test void testSnowflakeStartsWithFunction() {
- final SqlOperatorFixture f = fixture().withLibrary(SqlLibrary.SNOWFLAKE);
- f.setFor(SqlLibraryOperators.STARTSWITH);
- f.checkBoolean("startswith('12345', '123')", true);
- f.checkBoolean("startswith('12345', '1243')", false);
- f.checkBoolean("startswith(x'11', x'11')", true);
- f.checkBoolean("startswith(x'112211', x'33')", false);
- f.checkFails("^startswith('aabbcc', x'aa')^",
- "Cannot apply 'STARTSWITH' to arguments of type "
- + "'STARTSWITH\\(<CHAR\\(6\\)>, <BINARY\\(1\\)>\\)'\\. Supported "
- + "form\\(s\\): 'STARTSWITH\\(<STRING>, <STRING>\\)'",
- false);
- f.checkNull("startswith(null, null)");
- f.checkNull("startswith('12345', null)");
- f.checkNull("startswith(null, '123')");
- f.checkBoolean("startswith('', '123')", false);
- f.checkBoolean("startswith('', '')", true);
- f.checkNull("startswith(x'aa', null)");
- f.checkNull("startswith(null, x'aa')");
- f.checkBoolean("startswith(x'1234', x'')", true);
- f.checkBoolean("startswith(x'', x'123456')", false);
- f.checkBoolean("startswith(x'', x'')", true);
+ static Stream<FunctionAlias> startsWithAliases() {
+ return Stream.of(
+ FunctionAlias.of(
+ SqlLibraryOperators.STARTS_WITH,
+ "starts_with", SqlLibrary.BIG_QUERY, SqlLibrary.POSTGRESQL),
+ FunctionAlias.of(SqlLibraryOperators.STARTSWITH, "startswith", SqlLibrary.SNOWFLAKE));
Review Comment:
Do we need to pass the String names in or could we just use the `.name()` of the operator?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "julianhyde (via GitHub)" <gi...@apache.org>.
julianhyde commented on PR #3590:
URL: https://github.com/apache/calcite/pull/3590#issuecomment-1871348454
Is this PR just a proof of concept? If so, let’s not merge the PoC, let’s merge a commit that does the actual task - reduces duplication of testing for aliased functions. By all means give Sergey co-author credit in that commit if appropriate. JulianOn Dec 27, 2023, at 14:07, Tanner Clary ***@***.***> wrote:
It's still marked as draft for some reason.
I converted to ready for review, hope that's alright.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: ***@***.***>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "julianhyde (via GitHub)" <gi...@apache.org>.
julianhyde commented on code in PR #3590:
URL: https://github.com/apache/calcite/pull/3590#discussion_r1434597746
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -13686,6 +13673,31 @@ void testCastTruncates(CastType castType, SqlOperatorFixture f) {
}
}
+ static class AliasInfo {
+ private final SqlFunction function;
+ private final String alias;
+ private final SqlLibrary[] libraries;
+
+ private AliasInfo(SqlFunction function, String alias, SqlLibrary[] libraries) {
Review Comment:
Use a better name than `AliasInfo`. Info means data, after all. Maybe `FunctionAlias`. Also, move it to the end of the file.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #3590:
URL: https://github.com/apache/calcite/pull/3590#discussion_r1434660313
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -8897,56 +8898,44 @@ private void testCurrentDateFunc(Pair<String, Hook.Closeable> pair) {
f0.forEachLibrary(list(SqlLibrary.BIG_QUERY, SqlLibrary.ORACLE), consumer);
}
- @Test void testStartsWithFunction() {
+ /** Tests the {@code STARTS_WITH} and {@code STARTSWITH} operator. */
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("startsWithAliases")
+ void testStartsWithFunction2(FunctionAlias functionAlias) {
final SqlOperatorFixture f0 = fixture();
- f0.setFor(SqlLibraryOperators.STARTS_WITH);
+ final SqlFunction function = functionAlias.function;
+ f0.setFor(function);
+ final String alias = functionAlias.alias;
final Consumer<SqlOperatorFixture> consumer = f -> {
- f.checkBoolean("starts_with('12345', '123')", true);
- f.checkBoolean("starts_with('12345', '1243')", false);
- f.checkBoolean("starts_with(x'11', x'11')", true);
- f.checkBoolean("starts_with(x'112211', x'33')", false);
- f.checkFails("^starts_with('aabbcc', x'aa')^",
- "Cannot apply 'STARTS_WITH' to arguments of type "
- + "'STARTS_WITH\\(<CHAR\\(6\\)>, <BINARY\\(1\\)>\\)'\\. Supported "
- + "form\\(s\\): 'STARTS_WITH\\(<STRING>, <STRING>\\)'",
+ f.checkBoolean(alias + "('12345', '123')", true);
Review Comment:
Your proposal works for standard function syntax, but sql is a weird language. But your proposal may be good enough for most use 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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "julianhyde (via GitHub)" <gi...@apache.org>.
julianhyde commented on code in PR #3590:
URL: https://github.com/apache/calcite/pull/3590#discussion_r1434594909
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -8897,56 +8898,42 @@ private void testCurrentDateFunc(Pair<String, Hook.Closeable> pair) {
f0.forEachLibrary(list(SqlLibrary.BIG_QUERY, SqlLibrary.ORACLE), consumer);
}
- @Test void testStartsWithFunction() {
Review Comment:
Need a comment saying that it tests STARTS_WITH and STARTSWITH.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #3590:
URL: https://github.com/apache/calcite/pull/3590#issuecomment-1867056620
You leave the queries unchanged, and then you use a shuttle to replace the use of `starts_with` with `startswith`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin closed pull request #3590: [CALCITE-6172] PoC for parameterized tests
URL: https://github.com/apache/calcite/pull/3590
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #3590:
URL: https://github.com/apache/calcite/pull/3590#discussion_r1435295636
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -8897,56 +8898,44 @@ private void testCurrentDateFunc(Pair<String, Hook.Closeable> pair) {
f0.forEachLibrary(list(SqlLibrary.BIG_QUERY, SqlLibrary.ORACLE), consumer);
}
- @Test void testStartsWithFunction() {
+ /** Tests the {@code STARTS_WITH} and {@code STARTSWITH} operator. */
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("startsWithAliases")
+ void testStartsWithFunction2(FunctionAlias functionAlias) {
final SqlOperatorFixture f0 = fixture();
- f0.setFor(SqlLibraryOperators.STARTS_WITH);
+ final SqlFunction function = functionAlias.function;
+ f0.setFor(function);
+ final String alias = functionAlias.alias;
final Consumer<SqlOperatorFixture> consumer = f -> {
- f.checkBoolean("starts_with('12345', '123')", true);
- f.checkBoolean("starts_with('12345', '1243')", false);
- f.checkBoolean("starts_with(x'11', x'11')", true);
- f.checkBoolean("starts_with(x'112211', x'33')", false);
- f.checkFails("^starts_with('aabbcc', x'aa')^",
- "Cannot apply 'STARTS_WITH' to arguments of type "
- + "'STARTS_WITH\\(<CHAR\\(6\\)>, <BINARY\\(1\\)>\\)'\\. Supported "
- + "form\\(s\\): 'STARTS_WITH\\(<STRING>, <STRING>\\)'",
+ f.checkBoolean(alias + "('12345', '123')", true);
Review Comment:
i put it in a separate commit here to see how it could look like
https://github.com/apache/calcite/pull/3590/commits/88fc66326964d1019de37b9b924445ac5648ad6e
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "julianhyde (via GitHub)" <gi...@apache.org>.
julianhyde commented on PR #3590:
URL: https://github.com/apache/calcite/pull/3590#issuecomment-1867061770
@mihaibudiu The danger with your approach is that, by working on the AST, you automatically fix errors. E.g. you might accidentally change STARTSWITH to STARTS_WITH and not notice that STARTSWITH is a reserved word. Or the unparser might convert things to upper-case.
For this, I favor a brute force approach that generates strings.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "tanclary (via GitHub)" <gi...@apache.org>.
tanclary commented on PR #3590:
URL: https://github.com/apache/calcite/pull/3590#issuecomment-1870656854
> It's still marked as draft for some reason.
I converted to ready for review, hope that's alright.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #3590:
URL: https://github.com/apache/calcite/pull/3590#issuecomment-1867057131
It's not obvious that it's simpler than your solution, but it is optimized towards not changing the tested queries. Fewer chances to introduce errors during the manual rewrite.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #3590:
URL: https://github.com/apache/calcite/pull/3590#discussion_r1434637134
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -8897,56 +8898,44 @@ private void testCurrentDateFunc(Pair<String, Hook.Closeable> pair) {
f0.forEachLibrary(list(SqlLibrary.BIG_QUERY, SqlLibrary.ORACLE), consumer);
}
- @Test void testStartsWithFunction() {
+ /** Tests the {@code STARTS_WITH} and {@code STARTSWITH} operator. */
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("startsWithAliases")
+ void testStartsWithFunction2(FunctionAlias functionAlias) {
final SqlOperatorFixture f0 = fixture();
- f0.setFor(SqlLibraryOperators.STARTS_WITH);
+ final SqlFunction function = functionAlias.function;
+ f0.setFor(function);
+ final String alias = functionAlias.alias;
final Consumer<SqlOperatorFixture> consumer = f -> {
- f.checkBoolean("starts_with('12345', '123')", true);
- f.checkBoolean("starts_with('12345', '1243')", false);
- f.checkBoolean("starts_with(x'11', x'11')", true);
- f.checkBoolean("starts_with(x'112211', x'33')", false);
- f.checkFails("^starts_with('aabbcc', x'aa')^",
- "Cannot apply 'STARTS_WITH' to arguments of type "
- + "'STARTS_WITH\\(<CHAR\\(6\\)>, <BINARY\\(1\\)>\\)'\\. Supported "
- + "form\\(s\\): 'STARTS_WITH\\(<STRING>, <STRING>\\)'",
+ f.checkBoolean(alias + "('12345', '123')", true);
Review Comment:
Do we need then `"%function%`?
May be just name this method `for` or `applyFor` and use it like
```java
f.checkBoolean(alias.applyFor("('12345', '1234')"));
```
?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on PR #3590:
URL: https://github.com/apache/calcite/pull/3590#issuecomment-1867055416
I didn't get how shuttle could help with different `SQLLibraries` per alias...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3590:
URL: https://github.com/apache/calcite/pull/3590#issuecomment-1868028271
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3590) **Quality Gate passed**
Kudos, no new issues were introduced!
[0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3590&resolved=false&inNewCodePeriod=true)
[0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3590&resolved=false&inNewCodePeriod=true)
[100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3590&metric=new_coverage&view=list)
[0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3590&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3590)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "tanclary (via GitHub)" <gi...@apache.org>.
tanclary commented on code in PR #3590:
URL: https://github.com/apache/calcite/pull/3590#discussion_r1435298880
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -8897,56 +8899,43 @@ private void testCurrentDateFunc(Pair<String, Hook.Closeable> pair) {
f0.forEachLibrary(list(SqlLibrary.BIG_QUERY, SqlLibrary.ORACLE), consumer);
}
- @Test void testStartsWithFunction() {
+ /** Tests the {@code STARTS_WITH} and {@code STARTSWITH} operator. */
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("startsWithAliases")
+ void testStartsWithFunction2(FunctionAlias functionAlias) {
Review Comment:
I think this is looking good, if we merge it you can remove the 2
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on code in PR #3590:
URL: https://github.com/apache/calcite/pull/3590#discussion_r1435295317
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -8897,56 +8898,44 @@ private void testCurrentDateFunc(Pair<String, Hook.Closeable> pair) {
f0.forEachLibrary(list(SqlLibrary.BIG_QUERY, SqlLibrary.ORACLE), consumer);
}
- @Test void testStartsWithFunction() {
+ /** Tests the {@code STARTS_WITH} and {@code STARTSWITH} operator. */
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("startsWithAliases")
+ void testStartsWithFunction2(FunctionAlias functionAlias) {
final SqlOperatorFixture f0 = fixture();
- f0.setFor(SqlLibraryOperators.STARTS_WITH);
+ final SqlFunction function = functionAlias.function;
+ f0.setFor(function);
+ final String alias = functionAlias.alias;
final Consumer<SqlOperatorFixture> consumer = f -> {
- f.checkBoolean("starts_with('12345', '123')", true);
- f.checkBoolean("starts_with('12345', '1243')", false);
- f.checkBoolean("starts_with(x'11', x'11')", true);
- f.checkBoolean("starts_with(x'112211', x'33')", false);
- f.checkFails("^starts_with('aabbcc', x'aa')^",
- "Cannot apply 'STARTS_WITH' to arguments of type "
- + "'STARTS_WITH\\(<CHAR\\(6\\)>, <BINARY\\(1\\)>\\)'\\. Supported "
- + "form\\(s\\): 'STARTS_WITH\\(<STRING>, <STRING>\\)'",
+ f.checkBoolean(alias + "('12345', '123')", true);
+ f.checkBoolean(alias + "('12345', '1243')", false);
+ f.checkBoolean(alias + "(x'11', x'11')", true);
+ f.checkBoolean(alias + "(x'112211', x'33')", false);
+ f.checkFails("^" + alias + "('aabbcc', x'aa')^",
+ "Cannot apply '" + function.getName() + "' to arguments of type "
+ + "'" + function.getName() + "\\(<CHAR\\(6\\)>, <BINARY\\(1\\)>\\)'\\. Supported "
+ + "form\\(s\\): '" + function.getName() + "\\(<STRING>, <STRING>\\)'",
false);
- f.checkNull("starts_with(null, null)");
- f.checkNull("starts_with('12345', null)");
- f.checkNull("starts_with(null, '123')");
- f.checkBoolean("starts_with('', '123')", false);
- f.checkBoolean("starts_with('', '')", true);
- f.checkNull("starts_with(x'aa', null)");
- f.checkNull("starts_with(null, x'aa')");
- f.checkBoolean("starts_with(x'1234', x'')", true);
- f.checkBoolean("starts_with(x'', x'123456')", false);
- f.checkBoolean("starts_with(x'', x'')", true);
+ f.checkNull(alias + "(null, null)");
+ f.checkNull(alias + "('12345', null)");
+ f.checkNull(alias + "(null, '123')");
+ f.checkBoolean(alias + "('', '123')", false);
+ f.checkBoolean(alias + "('', '')", true);
+ f.checkNull(alias + "(x'aa', null)");
+ f.checkNull(alias + "(null, x'aa')");
+ f.checkBoolean(alias + "(x'1234', x'')", true);
+ f.checkBoolean(alias + "(x'', x'123456')", false);
+ f.checkBoolean(alias + "(x'', x'')", true);
};
- f0.forEachLibrary(list(SqlLibrary.BIG_QUERY, SqlLibrary.POSTGRESQL), consumer);
+ f0.forEachLibrary(list(functionAlias.libraries), consumer);
}
- /** Tests for Snowflake's {@code STARTSWITH} function. */
- @Test void testSnowflakeStartsWithFunction() {
- final SqlOperatorFixture f = fixture().withLibrary(SqlLibrary.SNOWFLAKE);
- f.setFor(SqlLibraryOperators.STARTSWITH);
- f.checkBoolean("startswith('12345', '123')", true);
- f.checkBoolean("startswith('12345', '1243')", false);
- f.checkBoolean("startswith(x'11', x'11')", true);
- f.checkBoolean("startswith(x'112211', x'33')", false);
- f.checkFails("^startswith('aabbcc', x'aa')^",
- "Cannot apply 'STARTSWITH' to arguments of type "
- + "'STARTSWITH\\(<CHAR\\(6\\)>, <BINARY\\(1\\)>\\)'\\. Supported "
- + "form\\(s\\): 'STARTSWITH\\(<STRING>, <STRING>\\)'",
- false);
- f.checkNull("startswith(null, null)");
- f.checkNull("startswith('12345', null)");
- f.checkNull("startswith(null, '123')");
- f.checkBoolean("startswith('', '123')", false);
- f.checkBoolean("startswith('', '')", true);
- f.checkNull("startswith(x'aa', null)");
- f.checkNull("startswith(null, x'aa')");
- f.checkBoolean("startswith(x'1234', x'')", true);
- f.checkBoolean("startswith(x'', x'123456')", false);
- f.checkBoolean("startswith(x'', x'')", true);
+ static Stream<FunctionAlias> startsWithAliases() {
+ return Stream.of(
+ FunctionAlias.of(
+ SqlLibraryOperators.STARTS_WITH,
+ "starts_with", SqlLibrary.BIG_QUERY, SqlLibrary.POSTGRESQL),
+ FunctionAlias.of(SqlLibraryOperators.STARTSWITH, "startswith", SqlLibrary.SNOWFLAKE));
Review Comment:
yes, makes sense, changed it, also added similar approach to retrieve libraries
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #3590:
URL: https://github.com/apache/calcite/pull/3590#issuecomment-1870655040
It's still marked as draft for some reason.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on code in PR #3590:
URL: https://github.com/apache/calcite/pull/3590#discussion_r1434613012
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -8897,56 +8898,44 @@ private void testCurrentDateFunc(Pair<String, Hook.Closeable> pair) {
f0.forEachLibrary(list(SqlLibrary.BIG_QUERY, SqlLibrary.ORACLE), consumer);
}
- @Test void testStartsWithFunction() {
+ /** Tests the {@code STARTS_WITH} and {@code STARTSWITH} operator. */
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("startsWithAliases")
+ void testStartsWithFunction2(FunctionAlias functionAlias) {
final SqlOperatorFixture f0 = fixture();
- f0.setFor(SqlLibraryOperators.STARTS_WITH);
+ final SqlFunction function = functionAlias.function;
+ f0.setFor(function);
+ final String alias = functionAlias.alias;
final Consumer<SqlOperatorFixture> consumer = f -> {
- f.checkBoolean("starts_with('12345', '123')", true);
- f.checkBoolean("starts_with('12345', '1243')", false);
- f.checkBoolean("starts_with(x'11', x'11')", true);
- f.checkBoolean("starts_with(x'112211', x'33')", false);
- f.checkFails("^starts_with('aabbcc', x'aa')^",
- "Cannot apply 'STARTS_WITH' to arguments of type "
- + "'STARTS_WITH\\(<CHAR\\(6\\)>, <BINARY\\(1\\)>\\)'\\. Supported "
- + "form\\(s\\): 'STARTS_WITH\\(<STRING>, <STRING>\\)'",
+ f.checkBoolean(alias + "('12345', '123')", true);
Review Comment:
Another possible suggestion is to have the alias implement a "rewrite" method which rewrites a specific template. Then you can write tests like `f.checkBoolean(alias.rewrite("%function%('12345', '1234')"))`. But I don't know if the readability of the test improves 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-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #3590:
URL: https://github.com/apache/calcite/pull/3590#issuecomment-1867101890
## [](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3590) **Quality Gate passed**
Kudos, no new issues were introduced!
[0 New issues](https://sonarcloud.io/project/issues?id=apache_calcite&pullRequest=3590&resolved=false&inNewCodePeriod=true)
[0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_calcite&pullRequest=3590&resolved=false&inNewCodePeriod=true)
[100.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3590&metric=new_coverage&view=list)
[0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_calcite&pullRequest=3590&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache_calcite&pullRequest=3590)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "snuyanzin (via GitHub)" <gi...@apache.org>.
snuyanzin commented on PR #3590:
URL: https://github.com/apache/calcite/pull/3590#issuecomment-1905433095
closing since the PR was merged
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [CALCITE-6172] PoC for parameterized tests [calcite]
Posted by "mihaibudiu (via GitHub)" <gi...@apache.org>.
mihaibudiu commented on PR #3590:
URL: https://github.com/apache/calcite/pull/3590#issuecomment-1888021698
This has developed a conflict, can you please fix it and I will merge.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org