-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3959 instr #2
base: joey
Are you sure you want to change the base?
3959 instr #2
Conversation
39b2571
to
aa66da6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job!!! Left some mainly minor comments, only other suggestion would be to add some quidem tests to BigQuery.iq, wouldn't say its mandatory, just an idea. Awesome first draft!
final int from0 = from - 1; // 0-based | ||
if (from0 > s.length() || from0 < 0) { | ||
if (from == 0) { | ||
throw new IllegalArgumentException("From position cannot be zero"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think most exceptions thrown in this class are stored in the RESOURCES here. You could add an entry.
final int from0 = from - 1; | ||
if (from0 > s.length() || from0 < 0) { | ||
if (from == 0) { | ||
throw new IllegalArgumentException("From position cannot be zero"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as above, could be useful just so this doesn't have to be retyped each time.
if (from > 0) { | ||
final int from0 = from - 1; // 0-based | ||
if (from0 > s.length() || from0 < 0) { | ||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if from0 == s.length()? Should this also return 0 since you can't get the 1-based (n+1)th position of a string of n characters? This would mean from > s.length(). Just curious
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're so right, great call
if (from == 0) { | ||
return 0; | ||
} | ||
from -= (s.length() + 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know if this could be helpful but it seems like there's a lot of checking to determine if FROM is a valid value or not, could a helper be useful? This logic is crazy so I don't know if it would help that much or not, just a thought.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I think there's definitely some simplifying that could be done, especially with all the +1s -1s and the like flying around. I'll look into it
final String query = "SELECT INSTR('A', 'ABC', 1, 1) from \"product\""; | ||
final String expected = "SELECT INSTR('A', 'ABC', 1, 1)\n" | ||
+ "FROM foodmart.product"; | ||
final Sql sql = fixture().withBigQuery().withLibrary(SqlLibrary.BIG_QUERY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
think you can do something like sql(query).withBigQuery().withLibrary(SqlLibrary.BIG_QUERY).ok(expected); shouldn't need to create Sql object i dont think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also if the function is valid for other libraries, could be a good idea to test with those libraries as well
assertThat(-1, is(position("f", "abcdec", 1, 1))); | ||
assertThat(-1, is(position("c", "abcdec", 1, 3))); | ||
try { | ||
int i = position("c", "abcdec", 0, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
based testing 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually made me realize those tests were wrong lol, appreciate the comment
site/_docs/reference.md
Outdated
@@ -2693,6 +2693,7 @@ BigQuery's type system uses confusingly different names for types and functions: | |||
| b o | GREATEST(expr [, expr ]*) | Returns the greatest of the expressions | |||
| b h s | IF(condition, value1, value2) | Returns *value1* if *condition* is TRUE, *value2* otherwise | |||
| b | IFNULL(value1, value2) | Equivalent to `NVL(value1, value2)` | |||
| b o | INSTR(string1, string2[, int1, int2]) | return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just reminder to update this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
@Test void testLocalTimeFuncWithCurrentTime() { | ||
testLocalTimeFunc(currentTimeString(LOCAL_TZ)); | ||
} | ||
// @Tag("slow") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this meant to be commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh lol oops, commented out cause it was slow when running tests, nice catch!
@@ -6224,6 +6224,30 @@ private void testCurrentDateFunc(Pair<String, Hook.Closeable> pair) { | |||
f.checkNull("STRPOS(x'', null)"); | |||
} | |||
|
|||
@Test void testInstrFunction() { | |||
final SqlOperatorFixture f0 = fixture().setFor(SqlLibraryOperators.INSTR); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should add a test that ensures the function doesnt work unless its set for bigquery, you should also test against each library the function supports, not just bigquery. good example here.
8cf0c50
to
4179b7e
Compare
* Adds OAuth configs * Update configs
Add release notes. In the release notes for previous releases, change whitespace and formatting for consistency among releases, standardize on 'Postgres' rather than 'PostgreSQL', and move the 'Compatability' paragraph before the 'Breaking changes' section. Add users' aliases to .mailmap, so that the contributors list in the release notes contains people's real name. Fix a typo in FileReaderTest. Release candidate #1 introduced [CALCITE-6616] ClassNotFoundException: java.util.SequencedCollection at RelBuilder$Frame init The cause was compiling the release candidate using JDK 21, which caused the `interface SequencedCollection`, introduced in JDK 21, to be used in resolving methods. The fix (in release candidate #2) is to revert to JDK 8 for the release build (and revert the instructions in howto.md). We suspect that building with building with JDK 11 or 17 would also work. Revise template vote email. Fix the tag URL, add an end time for the vote, describe how to use 'code name (role)' vote format, sign using release manager's name. Close apache#3979
No description provided.