Apache DataFusion SQL Query Engine
Improve signature of get_field (#10569)
张林伟d4197520b5e9
diff --git a/datafusion/core/tests/expr_api/mod.rs b/datafusion/core/tests/expr_api/mod.rsindex 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.rsindex 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 functionspub 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