You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ja...@apache.org on 2023/06/05 15:34:43 UTC
[arrow-datafusion] branch main updated: fix Incorrect function-name matching (#6528)
This is an automated email from the ASF dual-hosted git repository.
jakevin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new d401802cd2 fix Incorrect function-name matching (#6528)
d401802cd2 is described below
commit d401802cd21449f0eafd8565a6a47487152c63f3
Author: parkma99 <84...@users.noreply.github.com>
AuthorDate: Mon Jun 5 23:34:36 2023 +0800
fix Incorrect function-name matching (#6528)
---
.../core/tests/sqllogictests/test_files/scalar.slt | 28 ++++++++++++++++++++++
datafusion/sql/src/expr/function.rs | 2 +-
datafusion/sql/tests/integration_test.rs | 10 ++++++++
3 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/datafusion/core/tests/sqllogictests/test_files/scalar.slt b/datafusion/core/tests/sqllogictests/test_files/scalar.slt
index fc327d741a..1c0c934ad1 100644
--- a/datafusion/core/tests/sqllogictests/test_files/scalar.slt
+++ b/datafusion/core/tests/sqllogictests/test_files/scalar.slt
@@ -1237,3 +1237,31 @@ SELECT arrow_typeof(1, 1);
# error message for wrong function signature (OneOf: fixed number of args of arbitrary types)
statement error Error during planning: No function matches the given name and argument types 'power\(Int64, Int64, Int64\)'. You might need to add explicit type casts.\n\tCandidate functions:\n\tpower\(Int64, Int64\)\n\tpower\(Float64, Float64\)
SELECT power(1, 2, 3);
+
+# turn off enable_ident_normalization
+statement ok
+set datafusion.sql_parser.enable_ident_normalization = false;
+
+query I
+SELECT LENGTH('str');
+----
+3
+
+query T
+SELECT CONCAT('Hello', 'World')
+----
+HelloWorld
+
+# turn on enable_ident_normalization
+statement ok
+set datafusion.sql_parser.enable_ident_normalization = true;
+
+query I
+SELECT LENGTH('str');
+----
+3
+
+query T
+SELECT CONCAT('Hello', 'World')
+----
+HelloWorld
diff --git a/datafusion/sql/src/expr/function.rs b/datafusion/sql/src/expr/function.rs
index 70489203b2..bc34a5c4d0 100644
--- a/datafusion/sql/src/expr/function.rs
+++ b/datafusion/sql/src/expr/function.rs
@@ -43,7 +43,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
// (e.g. "foo.bar") for function names yet
function.name.to_string()
} else {
- self.normalizer.normalize(function.name.0[0].clone())
+ crate::utils::normalize_ident(function.name.0[0].clone())
};
// next, scalar built-in
diff --git a/datafusion/sql/tests/integration_test.rs b/datafusion/sql/tests/integration_test.rs
index 892cf48d56..7161fa481c 100644
--- a/datafusion/sql/tests/integration_test.rs
+++ b/datafusion/sql/tests/integration_test.rs
@@ -80,6 +80,16 @@ fn parse_decimals() {
#[test]
fn parse_ident_normalization() {
let test_data = [
+ (
+ "SELECT LENGTH('str')",
+ "Ok(Projection: character_length(Utf8(\"str\"))\n EmptyRelation)",
+ false,
+ ),
+ (
+ "SELECT CONCAT('Hello', 'World')",
+ "Ok(Projection: concat(Utf8(\"Hello\"), Utf8(\"World\"))\n EmptyRelation)",
+ false,
+ ),
(
"SELECT age FROM person",
"Ok(Projection: person.age\n TableScan: person)",