Youwei Wang has uploaded a new change for review.

  http://gerrit.cloudera.org:8080/4474

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: SELECT TRIM(where, characters, string_to_be_trimmed);
  where: enumerate values, available choices are: 
left/leading/right/trailing/both:
    left/leading means trimming characters from the start of the source string;
    right/trailing means trimming characters from the end of the source string;
    both means trimming characters from both ends of the source string;
  Note: option is case-insensitive, which means 'left' equals 'LeFt'.
  characters: the characters to trim, which is represented as a string;
  string_to_be_trimmed: the source string to trim;
  Examples:
  select btrim('left', 'a%', 'abc%%defg%%%%%'); returns 'bc%%defg%%%%%';
  select btrim('right', 'fg%', 'abc%%defg%%%%%'); returns 'abc%%de';
  select btrim('leading', 'ab%', 'abc%%defg%%%%%'); returns 'c%%defg%%%%%';
  select btrim('trailing', 'bfg%', 'abc%%defg%%%%%'); returns 'abc%%de';
  select btrim('both', 'abfg%', 'abc%%defg%%%%%'); returns 'c%%de';

Form #2: Standard SQL syntax (Core SQL feature ID E021-09)
  Syntax: SELECT TRIM(where characters FROM string_to_be_trimmed);
  where: enumerate values, available choices are: leading/trailing/both:
  Note: option is case-insensitive, which means 'leading' equals 'LeADinG'.
  Note: left and right are Impala keywords, they are not available in this 
syntax.
  characters: the characters to trim, which is represented as a string;
  string_to_be_trimmed: the source string to trim;
  Examples:
  select btrim(leading 'ab%' from 'abc%%defg%%%%%'); returns 'c%%defg%%%%%';
  select btrim(trailing 'bfg%' from 'abc%%defg%%%%%'); returns 'abc%%de';
  select 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 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
7 files changed, 244 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/74/4474/1
-- 
To view, visit http://gerrit.cloudera.org:8080/4474
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4753c608b0b00569bf8c5e95b132df6df358e602
Gerrit-PatchSet: 1
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Owner: Youwei Wang <youwei.a.w...@intel.com>

Reply via email to