impala-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John Russell (Code Review)" <>
Subject [Impala-ASF-CR] IMPALA-3973: optional 2nd and 3rd arguments for instr().
Date Sat, 07 Jan 2017 01:56:57 GMT
John Russell has posted comments on this change.

Change subject: IMPALA-3973: optional 2nd and 3rd arguments for instr().

Patch Set 2:

File docs/topics/impala_string_functions.xml:

PS2, Line 335: 1
> Can the occurrence argument be 0?
Same as the "off the end of the string" possibility below. The 'occurrence' arg is 1-based
like the 'position' arg, and anything out of range produces a 0 result.

PS2, Line 349: 7
> What if occurrence is off the end of the string?
That one's covered by

select instr('foo bar bletch', 'b', 20, 1);

below. I grouped all the zero-returning examples together because there are several kinds
of nonsensical argument combinations. Why don't I clarify that theme of out-of-range arguments
in the intro text on line 365.

PS2, Line 395: negative position argument
> Can the occurrence argument be zero or negative?
That particular circumstance causes an error instead of a zero return value:

select instr('foo','f',1,-1);
ERROR: UDF ERROR: Invalid occurrence parameter to instr function: -1

I'm not sure if that's intentional or a exception that was intended to be caught but wasn't.
(How do I @-mention Zoltan in a gerrit comment?)

Line 406: select instr('hello world','o',-1);
> Can you show an example with a negative position argument and an occurrence
Sure. In general, we try to be more detailed than Hive when it comes to providing examples
of built-in functions, and to be more on par with docs for mainstream DBs like MySQL.



Those counterparts often don't specify behavior for all cases of argument ranges for string
or math functions. But instr() is so commonly used and many counterparts don't have position/occurrence
for instr(), I agree that additional examples are worthwhile.

To view, visit
To unsubscribe, visit

Gerrit-MessageType: comment
Gerrit-Change-Id: I17268bdb480230938f94559fe1eabe34ac2448b7
Gerrit-PatchSet: 2
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Owner: John Russell <>
Gerrit-Reviewer: Jim Apple <>
Gerrit-Reviewer: John Russell <>
Gerrit-Reviewer: Zoltan Ivanfi <>
Gerrit-HasComments: Yes

View raw message