You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Oliver Lee (Jira)" <ji...@apache.org> on 2022/12/22 18:49:00 UTC

[jira] [Updated] (CALCITE-5451) Add LPAD() for BIG_QUERY

     [ https://issues.apache.org/jira/browse/CALCITE-5451?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oliver Lee updated CALCITE-5451:
--------------------------------
    Description: 
Adding in LPAD() for BIG_QUERY as per [https://g3doc.corp.google.com/company/teams/googlesql/reference/string_functions.md?cl=head#lpad] describes

 

{{LPAD(original_value, return_length[, pattern])}}
{quote}Returns a {{STRING}} or {{BYTES}} value that consists of {{original_value}} prepended with {{{}pattern{}}}. The {{return_length}} is an {{INT64}} that specifies the length of the returned value. If {{original_value}} is of type {{{}BYTES{}}}, {{return_length}} is the number of bytes. If {{original_value}} is of type {{{}STRING{}}}, {{return_length}} is the number of characters.

The default value of {{pattern}} is a blank space.

Both {{original_value}} and {{pattern}} must be the same data type.

If {{return_length}} is less than or equal to the {{original_value}} length, this function returns the {{original_value}} value, truncated to the value of {{{}return_length{}}}. For example, {{LPAD('hello world', 7);}} returns {{{}'hello w'{}}}.

If {{{}original_value{}}}, {{{}return_length{}}}, or {{pattern}} is {{{}NULL{}}}, this function returns {{{}NULL{}}}.

This function returns an error if:
 * {{return_length}} is negative
 * {{pattern}} is empty{quote}
 

Examples:

LPAD('12345', 8, 'a') -> "aaa12345"

LPAD('12345', 8) -> "   12345"

LPAD('12345', 8, 'ab') -> "aba12345"

LPAD('12345', 8, 'a') -> "aaa12345"

LPAD('12345', -3) -> error

LPAD('12345', 3, '') -> error

 

 

 

  was:
Adding in LPAD() for BIG_QUERY as per [https://g3doc.corp.google.com/company/teams/googlesql/reference/string_functions.md?cl=head#lpad] describes

 

 


> Add LPAD() for BIG_QUERY
> ------------------------
>
>                 Key: CALCITE-5451
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5451
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: Oliver Lee
>            Assignee: Oliver Lee
>            Priority: Minor
>
> Adding in LPAD() for BIG_QUERY as per [https://g3doc.corp.google.com/company/teams/googlesql/reference/string_functions.md?cl=head#lpad] describes
>  
> {{LPAD(original_value, return_length[, pattern])}}
> {quote}Returns a {{STRING}} or {{BYTES}} value that consists of {{original_value}} prepended with {{{}pattern{}}}. The {{return_length}} is an {{INT64}} that specifies the length of the returned value. If {{original_value}} is of type {{{}BYTES{}}}, {{return_length}} is the number of bytes. If {{original_value}} is of type {{{}STRING{}}}, {{return_length}} is the number of characters.
> The default value of {{pattern}} is a blank space.
> Both {{original_value}} and {{pattern}} must be the same data type.
> If {{return_length}} is less than or equal to the {{original_value}} length, this function returns the {{original_value}} value, truncated to the value of {{{}return_length{}}}. For example, {{LPAD('hello world', 7);}} returns {{{}'hello w'{}}}.
> If {{{}original_value{}}}, {{{}return_length{}}}, or {{pattern}} is {{{}NULL{}}}, this function returns {{{}NULL{}}}.
> This function returns an error if:
>  * {{return_length}} is negative
>  * {{pattern}} is empty{quote}
>  
> Examples:
> LPAD('12345', 8, 'a') -> "aaa12345"
> LPAD('12345', 8) -> "   12345"
> LPAD('12345', 8, 'ab') -> "aba12345"
> LPAD('12345', 8, 'a') -> "aaa12345"
> LPAD('12345', -3) -> error
> LPAD('12345', 3, '') -> error
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)