Skip to content

Error on NULL["field_name"]: The expression to get an indexed field is only valid for List, Struct, or Map types, got Null #10654

@alamb

Description

@alamb

Describe the bug

Expr::field is broken for ScalarValue::Null

After #10375 merged Expr::field is broken when we try and do it on ScalarValue::Null (in addition to #10565)

If you try to use it, you get an error:

The expression to get an indexed field is only valid for List, Struct, or Map types, got Null

To Reproduce

Add this test to expr_fn

#[test]
fn test_get_field_null() {
    evaluate_expr_test(
        lit(ScalarValue::Null).field("a"),
        vec![
            "+------------+",
            "| NULL literal",
        ],
    );
}

Fails with:

called Result::unwrap() on an Err value: Plan("The expression to get an indexed field is only valid for List, Struct, or Map types, got Null")

Expected behavior

Result should also be a NULL scalar

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingregressionSomething that used to work no longer does

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions