-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
fixes #1874 adding a substring extraction function, tests, and documentation #1986
Conversation
I was looking at the CACHE_TYPE_ID values and saw that TimeFormatExtractionFn.java and LookupExtractionFn.java both define it to 5. |
int len = dimValue.length(); | ||
|
||
if (index < len) { | ||
if (length > 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.
Is this check required ? At this point length
will be greater than 0 as we will return null
if the length is 0 at line 62 Strings.isNullOrEmpty(dimValue)
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.
sorry I confused length
with len
- ignore the comment
@clintropolis can we fix merge conflicts? I think this is almost ready to go |
Yep, will do this evening, along with other suggestions. |
8d7f385
to
aad2714
Compare
Bouncing for travis |
} | ||
|
||
@Override | ||
public byte[] getCacheKey() |
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.
thought @drcrallen want to have at lease one UT for getCacheKey ?
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.
Yes please :)
aad2714
to
d4ccf25
Compare
@clintropolis can we finish this off? |
|
@fjy I think it should be good to go now |
@Override | ||
public boolean preservesOrdering() | ||
{ | ||
return false; |
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.
this should be true when index == 0
to allow optimizations for this particular case.
d4ccf25
to
0067628
Compare
) | ||
{ | ||
|
||
Preconditions.checkArgument(length == null || length >= 0, "length must be positive"); |
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 length == 0 allowed? then it is expected to be "non-negative" not "positive"
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, from the code below it appears that length being 0 is not allowed.
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 probably should not allow a length of 0, since it just returns null across the board. I can change the check.
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.
@himanshug @clintropolis "positive" means >= 0
"strictly positive" means > 0
. If we don't allow 0, it should be say strictly positive to be clear.
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.
sure, will change message since I don't think having a length of 0 is very useful.
0067628
to
5a11426
Compare
5a11426
to
68ef5f4
Compare
👍 @himanshug @drcrallen i think this is ready to go |
👍 |
fixes #1874 adding a substring extraction function, tests, and documentation
SQL style substring extraction function, which takes an index and optionally a length, returning a substring of the dimension value starting from the index of size length, or the remainder of the string if it is shorter than length or length is not supplied. If the starting index is greater than the length of the dimension value, null is returned.