impala-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Youwei Wang (Code Review)" <ger...@cloudera.org>
Subject [Impala-ASF-CR] IMPALA-889: Add support for an ISO-SQL compliant trim() function.
Date Fri, 23 Sep 2016 01:32:11 GMT
Youwei Wang has uploaded a new patch set (#3).

Change subject: IMPALA-889: Add support for an ISO-SQL compliant trim() function.
......................................................................

IMPALA-889: Add support for an ISO-SQL compliant trim() function.

Syntax #1: BTRIM(string where, string trim_char_set, string target);
  Purpose: Removes all instances of one or more characters from the
    specified direction(s) of a STRING value.
  "where": Case-insensitive trim direction. Valid options are:
    'left|leading|right|trailing|both'. 'left|leading' means trimming
    characters from the start; 'right|trailing' means trimming
    characters from the end; 'both' means trimming characters from
    both sides. If this argument is NULL or non-NULL but none of the
    valid options, the function returns the "target" argument
    untouched. Blank argument causes parsing error.
  "trim_char_set": Case-sensitive characters to be removed. This
    argument is regarded as a character set going to be removed. So
    the occurrence order of each character doesn't matter and
    duplicated instance of same character will be ignored. If this
    argument is NULL, the function returns the target string
    untouched or it removes all occurrences of characters in the
    "trim_char_set" string according to the "where" option. Blank
    argument causes parsing error.
  "target": Case-sensitive target string to trim. Blank argument
    causes parsing error.
  Return type: string

  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';

Syntax #2: BTRIM(where string FROM string);
  Purpose: Identical as Form #1 except this form confirms the
    standard SQL syntax (Core SQL feature ID E021-09).
  "where": Case-insensitive trim direction, can be one of leading,
    trailing, or both. These options should be provided without
    single/double quotation marks since they are not string literals
    but identifiers. For left and right are Impala keywords, they are
    not available in this syntax.
  The second string argument corresponds to the "trim_char_set" in
  Syntax #1 and the third string argument corresponds to the "target"
  in Syntax #1. Same argument meaning and restriction from Syntax #1
  are applied.
  Return type: string

  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
M fe/src/test/java/com/cloudera/impala/analysis/AnalyzeExprsTest.java
7 files changed, 198 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/74/4474/3
-- 
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: 3
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Owner: Youwei Wang <youwei.a.wang@intel.com>
Gerrit-Reviewer: Jim Apple <jbapple@cloudera.com>
Gerrit-Reviewer: Mostafa Mokhtar <mmokhtar@cloudera.com>
Gerrit-Reviewer: Youwei Wang <youwei.a.wang@intel.com>

Mime
View raw message