Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

Nested SUBSTRING fails with INVALID_ARGUMENT error #705

Closed
smola opened this issue May 10, 2019 · 3 comments
Closed

Nested SUBSTRING fails with INVALID_ARGUMENT error #705

smola opened this issue May 10, 2019 · 3 comments
Assignees
Labels
3rd-party Third party compatibility blocked Some other issue is blocking this bug Something isn't working

Comments

@smola
Copy link
Collaborator

smola commented May 10, 2019

This works, both with positive and negative indexes:

SELECT
    repository_id,
    remote_fetch_url,
    SUBSTRING(remote_fetch_url, 18)
FROM remotes;
SELECT
    repository_id,
    remote_fetch_url,
    SUBSTRING(SUBSTRING(remote_fetch_url, 18), -4)
FROM remotes;

But this fails from gitbase-web with error:

Query Failed - unknown error: Code: INVALID_ARGUMENT syntax error at position 69 near 'substring' 

Running gitbase-0.20.0-rc1

@ajnavarro ajnavarro added the bug Something isn't working label May 13, 2019
@kuba-- kuba-- added the 3rd-party Third party compatibility label May 14, 2019
@kuba-- kuba-- self-assigned this May 15, 2019
@kuba--
Copy link
Contributor

kuba-- commented May 17, 2019

First we need to merge the fix in vitess: vitessio/vitess#4867

@kuba-- kuba-- added the blocked Some other issue is blocking this label May 20, 2019
@smola
Copy link
Collaborator Author

smola commented May 20, 2019

Just for reference, doing a second SUBSTRING in a subquery serves as a workaround. For example:

SELECT SUBSTRING(repository_id, 1, ARRAY_LENGTH(SPLIT(repository_id, ''))-4) AS b
FROM (
SELECT SUBSTRING(remote_fetch_url, 18) AS repository_id
FROM remotes
) AS q

@kuba--
Copy link
Contributor

kuba-- commented May 21, 2019

Yep, this is clear. The problem is SQL grammar - SUBSTRING expects static string or column name, so SUBSTRING(REPLACE(...)...) should not also work.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3rd-party Third party compatibility blocked Some other issue is blocking this bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants