This is an automated email from the ASF dual-hosted git repository.
jayzhan 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 d4197520b5 Improve signature of get_field (#10569)
d4197520b5 is described below
commit d4197520b5e9c4b68da34f54bc955b094bcb71e1
Author: 张林伟 <[email protected]>
AuthorDate: Sun May 19 13:59:08 2024 +0800
Improve signature of get_field (#10569)
---
datafusion/core/tests/expr_api/mod.rs | 4 ++--
datafusion/functions/src/core/mod.rs | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/datafusion/core/tests/expr_api/mod.rs
b/datafusion/core/tests/expr_api/mod.rs
index d7e839824b..db75a8c614 100644
--- a/datafusion/core/tests/expr_api/mod.rs
+++ b/datafusion/core/tests/expr_api/mod.rs
@@ -61,7 +61,7 @@ fn test_eq_with_coercion() {
#[test]
fn test_get_field() {
evaluate_expr_test(
- get_field(col("props"), lit("a")),
+ get_field(col("props"), "a"),
vec![
"+------------+",
"| expr |",
@@ -77,7 +77,7 @@ fn test_get_field() {
#[test]
fn test_nested_get_field() {
evaluate_expr_test(
- get_field(col("props"), lit("a"))
+ get_field(col("props"), "a")
.eq(lit("2021-02-02"))
.or(col("id").eq(lit(1))),
vec![
diff --git a/datafusion/functions/src/core/mod.rs
b/datafusion/functions/src/core/mod.rs
index d60e6017dd..491e45c35a 100644
--- a/datafusion/functions/src/core/mod.rs
+++ b/datafusion/functions/src/core/mod.rs
@@ -43,7 +43,7 @@ make_udf_function!(coalesce::CoalesceFunc, COALESCE,
coalesce);
// Export the functions out of this package, both as expr_fn as well as a list
of functions
pub mod expr_fn {
- use datafusion_expr::Expr;
+ use datafusion_expr::{Expr, Literal};
/// returns NULL if value1 equals value2; otherwise it returns value1. This
/// can be used to perform the inverse operation of the COALESCE expression
@@ -83,8 +83,8 @@ pub mod expr_fn {
}
/// Returns the value of the field with the given name from the struct
- pub fn get_field(arg1: Expr, arg2: Expr) -> Expr {
- super::get_field().call(vec![arg1, arg2])
+ pub fn get_field(arg1: Expr, field_name: impl Literal) -> Expr {
+ super::get_field().call(vec![arg1, field_name.lit()])
}
/// Returns `coalesce(args...)`, which evaluates to the value of the first
expr which is not NULL
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]