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

Unsupported ast node in sqltorel: Substring #10258

Closed
appletreeisyellow opened this issue Apr 26, 2024 · 2 comments
Closed

Unsupported ast node in sqltorel: Substring #10258

appletreeisyellow opened this issue Apr 26, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@appletreeisyellow
Copy link
Contributor

appletreeisyellow commented Apr 26, 2024

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

@appletreeisyellow appletreeisyellow added the bug Something isn't working label Apr 26, 2024
@Jefffrey
Copy link
Contributor

Should be resolved by #10242

@appletreeisyellow
Copy link
Contributor Author

appletreeisyellow commented Apr 26, 2024

@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
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants