Registry Mirror
Skip to content

Unsupported ast node in sqltorel: Substring #10258

Closed

Description

@appletreeisyellow

Describe the bug

When upgrading DataFusion in InfluxData IOx, we found a regression that fc34dac brought in, which comes from the PR below:

For example, querying substring("region", 1, 2) errors with the following message:

Unsupported ast node in sqltorel: Substring { expr: Identifier(Ident { value: "region", quote_style: None }), substring_from: Some(Value(Number("1", false))), substring_for: Some(Value(Number("2", false))), special: true }

I verified that the previous commit (eb72deb) doesn't have this bug

To Reproduce

  1. on the latest apache/datafusion main branch
git co fc34dacdb9842cde4d056d5a659796ede4ae5e74
  1. build datafusion-cli locally
cd datafusion-cli
cargo build
  1. run datafusion-cli locally
./target/debug/datafusion-cli
  1. Then in datafusion-cli
DataFusion CLI v37.1.0

# create a table with one column
CREATE TABLE fruits (name VARCHAR(100));
INSERT INTO fruits (name) VALUES ('banana');
INSERT INTO fruits (name) VALUES ('apple');
0 row(s) fetched.
Elapsed 0.004 seconds.

+-------+
| count |
+-------+
| 1     |
+-------+
1 row(s) fetched.
Elapsed 0.004 seconds.

+-------+
| count |
+-------+
| 1     |
+-------+
1 row(s) fetched.
Elapsed 0.004 seconds.

> select * from fruits;
+--------+
| name   |
+--------+
| banana |
| apple  |
+--------+
2 row(s) fetched.
Elapsed 0.011 seconds.

> select substring("name", 1, 2) from fruits;
This feature is not implemented: Unsupported ast node in sqltorel: Substring { expr: Identifier(Ident { value: "name", quote_style: Some('"') }), substring_from: Some(Value(Number("1", false))), substring_for: Some(Value(Number("2", false))), special: true }

Expected behavior

> select substring("name", 1, 2) from fruits;
+---------------------------------------+
| substr(fruits.name,Int64(1),Int64(2)) |
+---------------------------------------+
| ba                                    |
| ap                                    |
+---------------------------------------+
2 row(s) fetched.
Elapsed 0.015 seconds.

I verified that substring() works fine when I built and ran the previous commit (eb72deb) locally

Additional context

No response

Activity

  1. added
    bug
    on Apr 26, 2024
  2. Jefffrey commented on Apr 26, 2024

    @Jefffrey
    Contributor

    Should be resolved by #10242

  3. appletreeisyellow commented on Apr 26, 2024

    @appletreeisyellow
    ContributorAuthor

    @Jefffrey I forgot to check the latest commits🤦‍♀️ Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions