[CALCITE-2572] Handle substring start position of less than 1#842
Closed
apilloud wants to merge 1 commit intoapache:masterfrom
Closed
[CALCITE-2572] Handle substring start position of less than 1#842apilloud wants to merge 1 commit intoapache:masterfrom
apilloud wants to merge 1 commit intoapache:masterfrom
Conversation
2 tasks
julianhyde
pushed a commit
to julianhyde/calcite
that referenced
this pull request
Sep 19, 2018
F21
pushed a commit
to F21/calcite
that referenced
this pull request
Jan 3, 2019
wangxlong
pushed a commit
to wangxlong/calcite
that referenced
this pull request
Feb 13, 2020
jamesstarr
pushed a commit
to jamesstarr/calcite
that referenced
this pull request
Aug 28, 2025
…Pilloud) Close apache#842 Change-Id: I3b1959cd2a49fab7878709201aa6fbe41e051c19
jamesstarr
pushed a commit
to jamesstarr/calcite
that referenced
this pull request
Mar 16, 2026
…Pilloud) Close apache#842 Change-Id: I3b1959cd2a49fab7878709201aa6fbe41e051c19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Calcite substring throws a IndexOutOfBoundsException with a position less than 1. Per the SQL standard, the position should be treated as the larger of the provided value and 1, however many implementations treat negative values as starting from the end of the string.
Extended standard:
https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions162.htm
https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_substring
https://spark.apache.org/docs/2.3.0/api/sql/index.html#substring
https://www.sqlite.org/lang_corefunc.html#substr
Follow the standard:
https://docs.microsoft.com/en-us/sql/t-sql/functions/substring-transact-sql?view=sql-server-2017
https://www.postgresql.org/docs/9.1/static/functions-string.html