Youwei Wang has uploaded a new patch set (#2). Change subject: IMPALA-889: Add support for ISO-SQL trim() ......................................................................
IMPALA-889: Add support for ISO-SQL trim() Add support for an ISO-SQL compliant trim() function. Form 1: Impala UDF calling Syntax: BTRIM(where, characters, string_to_be_trimmed); "where": an enumerate value denoting the trim direction. Available choices are: 'left|leading|right|trailing|both'. This field is case-insensitive, which means 'left' equals 'LeFt'. left|leading - trimming characters from the start of the source string; right|trailing - trimming characters from the end of the source string; both - trimming characters from both ends of the source string; "characters": the characters to trim, which are represented as a string. The order of such characters doesn't matter. Multiple occurrances of one same letter will be ignored. This field is case-sensitive. "string_to_be_trimmed": the source string to trim. This field is case-sensitive. Examples: btrim('left', 'a%', 'abc%%defg%%%%%'); returns 'bc%%defg%%%%%'; btrim('right', 'fg%', 'abc%%defg%%%%%'); returns 'abc%%de'; btrim('leading', 'ab%', 'abc%%defg%%%%%'); returns 'c%%defg%%%%%'; btrim('trailing', 'bfg%', 'abc%%defg%%%%%'); returns 'abc%%de'; btrim('both', 'abfg%', 'abc%%defg%%%%%'); returns 'c%%de'; Form 2: Standard SQL syntax (Core SQL feature ID E021-09) Syntax: BTRIM(where characters FROM string_to_be_trimmed); "where": this field has the same meaning as form 1. Available choices are: leading/trailing/both. Since left and right are Impala keywords, they are not available in this form. "characters": this field has the same meaning as form 1. "string_to_be_trimmed": this field has the same meaning as form 1. Examples: btrim(leading 'ab%' from 'abc%%defg%%%%%'); returns 'c%%defg%%%%%'; btrim(trailing 'bfg%' from 'abc%%defg%%%%%'); returns 'abc%%de'; btrim(both 'abfg%' from 'abc%%defg%%%%%'); returns 'c%%de'; Change-Id: I4753c608b0b00569bf8c5e95b132df6df358e602 --- M be/src/exprs/expr-test.cc M be/src/exprs/string-functions-ir.cc M be/src/exprs/string-functions.h M common/function-registry/impala_functions.py M common/thrift/Exprs.thrift M fe/src/main/cup/sql-parser.cup A fe/src/main/java/com/cloudera/impala/analysis/TrimExpr.java M fe/src/test/java/com/cloudera/impala/analysis/AnalyzeExprsTest.java 8 files changed, 295 insertions(+), 13 deletions(-) git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/74/4474/2 -- To view, visit http://gerrit.cloudera.org:8080/4474 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-MessageType: newpatchset Gerrit-Change-Id: I4753c608b0b00569bf8c5e95b132df6df358e602 Gerrit-PatchSet: 2 Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-Owner: Youwei Wang <youwei.a.w...@intel.com> Gerrit-Reviewer: Jim Apple <jbap...@cloudera.com>