Skip to content

Commit

Permalink
fix: no longer support the substring function (apache#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 <jeffrey.vo.australia@gmail.com>

---------

Co-authored-by: Jeffrey Vo <jeffrey.vo.australia@gmail.com>
  • Loading branch information
2 people authored and appletreeisyellow committed Apr 30, 2024
1 parent 4440267 commit 108abe7
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 108abe7

Please sign in to comment.