You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@impala.apache.org by "Wang, Youwei A" <yo...@intel.com> on 2016/07/08 00:56:59 UTC
Discussion about IMPALA-889: Add support for ISO-SQL trim()
Greetings everyone.
I am working on the JIRA IMPALA-889: Add support for ISO-SQL trim().
Corresponding JIRA link: http://issues.cloudera.org/browse/IMPALA-889
I found some ISO-SQL standard at this link: http://troels.arvin.dk/db/rdbms/#functions-TRIM
For your convenience, I transcript some critical part as following:
Core SQL feature ID E021-09: TRIM(where characters FROM string_to_be_trimmed)
where may be one of LEADING, TRAILING or BOTH-or omitted which implies BOTH.
characters indicates what character(s) to remove from the head and/or tail of the string.
It may be omitted which implies the value ' ' (space character).
In other words, the shortest form is TRIM(string_to_be_trimmed) which in effect means TRIM(BOTH ' ' FROM string_to_be_trimmed).
Trimming NULL returns NULL.
I have implemented one single UDF in the following form:
https://gerrit.cloudera.org/#/c/3213/
select trim(option, chars_to_trim, source_string);
According that SQL standard, there exists a SQL keyword "FROM" in the function parameter, which means we should modify the Impala SQL parser if we want to follow that definition strictly. This may make situation more complex.
If you have any idea about this, would you please share it with me?
Thank you! :)
Re: Discussion about IMPALA-889: Add support for ISO-SQL trim()
Posted by John Russell <jr...@cloudera.com>.
The extract() function already has a syntax variant, "extract(unit FROM timestamp)”. Are the building blocks there to code similar syntax for other functions?
John
> On Jul 8, 2016, at 9:33 AM, Jim Apple <jb...@cloudera.com> wrote:
>
> My feeling is that Impala should implement the standard, including the
> additional syntax.
>
> On Thu, Jul 7, 2016 at 5:56 PM, Wang, Youwei A <yo...@intel.com> wrote:
>> Greetings everyone.
>> I am working on the JIRA IMPALA-889: Add support for ISO-SQL trim().
>> Corresponding JIRA link: http://issues.cloudera.org/browse/IMPALA-889
>>
>> I found some ISO-SQL standard at this link: http://troels.arvin.dk/db/rdbms/#functions-TRIM
>> For your convenience, I transcript some critical part as following:
>>
>> Core SQL feature ID E021-09: TRIM(where characters FROM string_to_be_trimmed)
>> where may be one of LEADING, TRAILING or BOTH-or omitted which implies BOTH.
>> characters indicates what character(s) to remove from the head and/or tail of the string.
>> It may be omitted which implies the value ' ' (space character).
>> In other words, the shortest form is TRIM(string_to_be_trimmed) which in effect means TRIM(BOTH ' ' FROM string_to_be_trimmed).
>> Trimming NULL returns NULL.
>>
>> I have implemented one single UDF in the following form:
>> https://gerrit.cloudera.org/#/c/3213/
>> select trim(option, chars_to_trim, source_string);
>>
>> According that SQL standard, there exists a SQL keyword "FROM" in the function parameter, which means we should modify the Impala SQL parser if we want to follow that definition strictly. This may make situation more complex.
>>
>> If you have any idea about this, would you please share it with me?
>> Thank you! :)
Re: Discussion about IMPALA-889: Add support for ISO-SQL trim()
Posted by Jim Apple <jb...@cloudera.com>.
My feeling is that Impala should implement the standard, including the
additional syntax.
On Thu, Jul 7, 2016 at 5:56 PM, Wang, Youwei A <yo...@intel.com> wrote:
> Greetings everyone.
> I am working on the JIRA IMPALA-889: Add support for ISO-SQL trim().
> Corresponding JIRA link: http://issues.cloudera.org/browse/IMPALA-889
>
> I found some ISO-SQL standard at this link: http://troels.arvin.dk/db/rdbms/#functions-TRIM
> For your convenience, I transcript some critical part as following:
>
> Core SQL feature ID E021-09: TRIM(where characters FROM string_to_be_trimmed)
> where may be one of LEADING, TRAILING or BOTH-or omitted which implies BOTH.
> characters indicates what character(s) to remove from the head and/or tail of the string.
> It may be omitted which implies the value ' ' (space character).
> In other words, the shortest form is TRIM(string_to_be_trimmed) which in effect means TRIM(BOTH ' ' FROM string_to_be_trimmed).
> Trimming NULL returns NULL.
>
> I have implemented one single UDF in the following form:
> https://gerrit.cloudera.org/#/c/3213/
> select trim(option, chars_to_trim, source_string);
>
> According that SQL standard, there exists a SQL keyword "FROM" in the function parameter, which means we should modify the Impala SQL parser if we want to follow that definition strictly. This may make situation more complex.
>
> If you have any idea about this, would you please share it with me?
> Thank you! :)