You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2023/03/14 20:33:00 UTC

[jira] [Commented] (CALCITE-5585) Add STRPOS() Function (Enabled for BigQuery)

    [ https://issues.apache.org/jira/browse/CALCITE-5585?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17700368#comment-17700368 ] 

Julian Hyde commented on CALCITE-5585:
--------------------------------------

Sounds good, but let's stick to Calcite terminology. Character strings (which can be CHAR or VARCHAR) rather than {{STRING}}, binary strings (which can be BINARY or VARBINARY) rather than {{ByteString}}. Single-quotes for character literals.

It seems to be identical to the function in Postgres, Presto and DB2, so let's add those as supported libraries.

Except for the syntax it is identical to the standard {{POSITION}} function, so let's make sure that it shares as much implementation with {{POSITION}} as possible. Should {{STRPOS}} desugar to {{POSITION}}? Probably, yes.

> Add STRPOS() Function (Enabled for BigQuery)
> --------------------------------------------
>
>                 Key: CALCITE-5585
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5585
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: Tanner Clary
>            Assignee: Tanner Clary
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> BigQuery supports the {{STRPOS()}} function with accepts 2 {{STRINGS}} as arguments. The function returns the 1-based position of the first occurrence of the second string within the first (example below). If no occurrence is found, the function returns 0. The function also supports ByteStrings with the same behavior.
> EXAMPLE: {{STRPOS("abc", "bc")}} would return: {{2}}.
> EXAMPLE: {{STRPOS("abc", "d")}} would return: {{0}}.
> [BigQuery docs|https://cloud.google.com/bigquery/docs/reference/standard-sql/string_functions#strpos]



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