Skip to content

Return type of the struct function is always a struct with an empty list of fields #6597

@oridag

Description

@oridag

Describe the bug

Same as title

To Reproduce

use datafusion::prelude::*;
use datafusion_expr::BuiltinScalarFunction;#[tokio::main]
async fn main() -> datafusion::error::Result<()> {
    let ctx = SessionContext::new();
    ctx.register_csv("example", "tests/data/example.csv", CsvReadOptions::new()).await?;let df = ctx.table("example").await?;let f = Expr::ScalarFunction(datafusion_expr::expr::ScalarFunction {
        fun: BuiltinScalarFunction::Struct,
        args: vec![col("a"), col("b")],
    });let df2 = df.select(vec![f])?;
    df2.show().await?;
    Ok(())
}

Expected behavior

No error

Additional context

Returns the following error:

Error: ArrowError(InvalidArgumentError("column types must match schema types, expected Struct([]) but found Struct([Field { name: \"c0\", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, Field { name: \"c1\", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }]) at column index 0"))

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions