John Russell has posted comments on this change. Change subject: IMPALA-3973: optional 2nd and 3rd arguments for instr(). ......................................................................
Patch Set 2: (4 comments) http://gerrit.cloudera.org:8080/#/c/5589/2/docs/topics/impala_string_functions.xml 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. Hive: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-StringFunctions MySQL: http://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_instr 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 http://gerrit.cloudera.org:8080/5589 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-MessageType: comment Gerrit-Change-Id: I17268bdb480230938f94559fe1eabe34ac2448b7 Gerrit-PatchSet: 2 Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-Owner: John Russell <[email protected]> Gerrit-Reviewer: Jim Apple <[email protected]> Gerrit-Reviewer: John Russell <[email protected]> Gerrit-Reviewer: Zoltan Ivanfi <[email protected]> Gerrit-Reviewer: [email protected] Gerrit-HasComments: Yes
