Skip to content

Commit f8c623f

Browse files
jonahgaoJefffrey
andauthored
fix: no longer support the substring function (#10242)
* 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]>
1 parent fe10317 commit f8c623f

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

datafusion/sql/src/expr/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
467467
expr,
468468
substring_from,
469469
substring_for,
470-
special: false,
470+
special: _,
471471
} => self.sql_substring_to_expr(
472472
expr,
473473
substring_from,

datafusion/sqllogictest/test_files/expr.slt

+29
Original file line numberDiff line numberDiff line change
@@ -1871,6 +1871,17 @@ SELECT digest('','blake3');
18711871
----
18721872
af1349b9f5f9a1a6a0404dea36dcc9499bcb25c9adc112b7cc9a93cae41f3262
18731873

1874+
1875+
query T
1876+
SELECT substring('alphabet', 1)
1877+
----
1878+
alphabet
1879+
1880+
query T
1881+
SELECT substring('alphabet', 3, 2)
1882+
----
1883+
ph
1884+
18741885
query T
18751886
SELECT substring('alphabet' from 2 for 1);
18761887
----
@@ -1886,6 +1897,24 @@ SELECT substring('alphabet' for 1);
18861897
----
18871898
a
18881899

1900+
# The 'from' and 'for' parameters don't support string types, because they should be treated as
1901+
# regular expressions, which we have not implemented yet.
1902+
query error DataFusion error: Error during planning: No function matches the given name and argument types
1903+
SELECT substring('alphabet' FROM '3')
1904+
1905+
query error DataFusion error: Error during planning: No function matches the given name and argument types
1906+
SELECT substring('alphabet' FROM '3' FOR '2')
1907+
1908+
query error DataFusion error: Error during planning: No function matches the given name and argument types
1909+
SELECT substring('alphabet' FROM '3' FOR 2)
1910+
1911+
query error DataFusion error: Error during planning: No function matches the given name and argument types
1912+
SELECT substring('alphabet' FROM 3 FOR '2')
1913+
1914+
query error DataFusion error: Error during planning: No function matches the given name and argument types
1915+
SELECT substring('alphabet' FOR '2')
1916+
1917+
18891918
##### csv_query_nullif_divide_by_0
18901919

18911920

0 commit comments

Comments
 (0)