This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new f8c623fe04 fix: no longer support the `substring` function (#10242)
f8c623fe04 is described below

commit f8c623fe045d70a87eac8dc8620b74ff73be56d5
Author: Jonah Gao <[email protected]>
AuthorDate: Sat Apr 27 02:30:09 2024 +0800

    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]>
---
 datafusion/sql/src/expr/mod.rs              |  2 +-
 datafusion/sqllogictest/test_files/expr.slt | 29 +++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/datafusion/sql/src/expr/mod.rs b/datafusion/sql/src/expr/mod.rs
index 0d1db8a29c..13f559a0eb 100644
--- a/datafusion/sql/src/expr/mod.rs
+++ b/datafusion/sql/src/expr/mod.rs
@@ -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,
diff --git a/datafusion/sqllogictest/test_files/expr.slt 
b/datafusion/sqllogictest/test_files/expr.slt
index adc577f12f..ff63416b3a 100644
--- a/datafusion/sqllogictest/test_files/expr.slt
+++ b/datafusion/sqllogictest/test_files/expr.slt
@@ -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);
 ----
@@ -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
 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to