Skip to content

Commit

Permalink
fix: no longer support the substring function (#10242)
Browse files Browse the repository at this point in the history
* fix: no longer support the `substring` function

* enable from-for format

* update test comment

* review feedback

* review feedback

Co-authored-by: Jeffrey Vo <[email protected]>

---------

Co-authored-by: Jeffrey Vo <[email protected]>
  • Loading branch information
jonahgao and Jefffrey authored Apr 26, 2024
1 parent fe10317 commit f8c623f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion datafusion/sql/src/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
expr,
substring_from,
substring_for,
special: false,
special: _,
} => self.sql_substring_to_expr(
expr,
substring_from,
Expand Down
29 changes: 29 additions & 0 deletions datafusion/sqllogictest/test_files/expr.slt
Original file line number Diff line number Diff line change
Expand Up @@ -1871,6 +1871,17 @@ SELECT digest('','blake3');
----
af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262


query T
SELECT substring('alphabet', 1)
----
alphabet

query T
SELECT substring('alphabet', 3, 2)
----
ph

query T
SELECT substring('alphabet' from 2 for 1);
----
Expand All @@ -1886,6 +1897,24 @@ SELECT substring('alphabet' for 1);
----
a

# The 'from' and 'for' parameters don't support string types, because they should be treated as
# regular expressions, which we have not implemented yet.
query error DataFusion error: Error during planning: No function matches the given name and argument types
SELECT substring('alphabet' FROM '3')

query error DataFusion error: Error during planning: No function matches the given name and argument types
SELECT substring('alphabet' FROM '3' FOR '2')

query error DataFusion error: Error during planning: No function matches the given name and argument types
SELECT substring('alphabet' FROM '3' FOR 2)

query error DataFusion error: Error during planning: No function matches the given name and argument types
SELECT substring('alphabet' FROM 3 FOR '2')

query error DataFusion error: Error during planning: No function matches the given name and argument types
SELECT substring('alphabet' FOR '2')


##### csv_query_nullif_divide_by_0


Expand Down

0 comments on commit f8c623f

Please sign in to comment.