[
https://issues.apache.org/jira/browse/ASTERIXDB-2272?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16355901#comment-16355901
]
ASF subversion and git services commented on ASTERIXDB-2272:
------------------------------------------------------------
Commit 05802cc333ac6c036710867e9773d777e12d23e6 in asterixdb's branch
refs/heads/master from [~dlychagin-cb]
[ https://git-wip-us.apache.org/repos/asf?p=asterixdb.git;h=05802cc ]
[ASTERIXDB-2272][FUN] Count character positions from 0
- user model changes: yes
- storage format changes: no
- interface changes: no
Details:
- Count character positions in strings, binary from 0 instead of 1
- Affects following built-in functions:
position(), regexp_position(), substr()/subtring(),
sub_binary(), find-binary()
- Introduce new configuration property “compiler.stringoffset”
for backward compatibility
compiler.stringoffset = 0 - count from 0 (new default)
compiler.stringoffset = 1 - count from 1 (backwards-compatible setting)
Change-Id: Icdb2c241983d5f592b2695ef16eae9951518d7fd
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2342
Reviewed-by: Dmitry Lychagin <[email protected]>
Tested-by: Dmitry Lychagin <[email protected]>
> Change character positions inside a string from 1-based to 0-based
> ------------------------------------------------------------------
>
> Key: ASTERIXDB-2272
> URL: https://issues.apache.org/jira/browse/ASTERIXDB-2272
> Project: Apache AsterixDB
> Issue Type: Improvement
> Components: FUN - Functions
> Reporter: Dmitry Lychagin
> Assignee: Dmitry Lychagin
> Priority: Minor
>
> Change how string functions count character positions inside a string.
> Currently string functions position(), substring() and some others assume
> that the first character is at position 1.
> The proposal is to change the first position to 0, to better align with array
> element positions (which also start with 0), and other languages.
> This change will also apply to binary functions (below) and will be effective
> in both SQLPP and AQL.
>
> The following functions will be affected:
> position(),
> regexp_position(),
> substring()/substr(),
> sub_binary(),
> find_binary()
>
> This might be a disrupting change for some users so we will also introduce a
> cluster-wide configuration parameter (“compiler.stringoffset”) for backwards
> compatibility:
> compiler.stringoffset = 0 // first character position is assumed to be 0
> (new default)
> compiler.stringoffset = 1 // first character position is assumed to be 1
> (backwards-compatible setting)
>
> The query migration path is straightforward, for example:
> substring(“abcdef”, 1) will need to be changed to substring(“abcdef”, 0),
> etc, same applies to sub_binary().
> position(), regexp_position(), and find_binary() will return one less than
> they used to, but would still return -1 if the value is not found.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)