Skip to content

Commit

Permalink
Improve signature of get_field (#10569)
Browse files Browse the repository at this point in the history
  • Loading branch information
lewiszlw authored May 19, 2024
1 parent e7858ff commit d419752
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions datafusion/core/tests/expr_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 |",
Expand All @@ -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![
Expand Down
6 changes: 3 additions & 3 deletions datafusion/functions/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d419752

Please sign in to comment.