Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String extract index out of range #938

Closed
acquamarin opened this issue Nov 8, 2022 · 0 comments
Closed

String extract index out of range #938

acquamarin opened this issue Nov 8, 2022 · 0 comments
Assignees

Comments

@acquamarin
Copy link
Collaborator

acquamarin commented Nov 8, 2022

  1. If the string extract index is out of range, we are outputing the last character in the string.
    Example:
    GF:
graphflowdb> match (o:org1) return "text"[100]
>> Number of output tuples: 1
>> Compiling time: 0.47ms
>> Executing time: 0.72ms
-----
| t |
-----

DUCKDB:

D select 'text'[20];
┌────────────┐
│ 'text'[20] │
├────────────┤
│            │
└────────────┘

We should also output nothing if the index is out of range

  1. If the left index is a negative number and out of range or 0, we are outputing the entire string, however duckdb outputs nothing.
    Example:
    GF:
graphflowdb> match (o:org1) retURN left("123", -5)
>> Number of output tuples: 4
>> Compiling time: 0.90ms
>> Executing time: 0.61ms
-------
| 123 |
-------

DUCKDB:

D select left('123', -5);
┌─────────────────┐
│ left('123', -5) │
├─────────────────┤
│                 │
└─────────────────┘

  1. lpad: If the length is a negative number, the lpad will cause an assertion error:
graphflowdb> match (o:org1) retURN lpad("123", -100, ">")
graphflowdb: src/common/in_mem_overflow_buffer.cpp:7: uint8_t* graphflow::common::InMemOverflowBuffer::allocateSpace(uint64_t): Assertion `size <= LARGE_PAGE_SIZE' failed.
Aborted (core dumped)

Duckdb:

D select lpad('123', -100, '>');
┌────────────────────────┐
│ lpad('123', -100, '>') │
├────────────────────────┤
│                        │
└────────────────────────┘
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants