Skip to content

Regression in 43.0.0: coalesce no longer works between Utf8 and Utf8View columns #13568

Closed
@ttencate

Description

@ttencate

Describe the bug

coalesce() no longer considers Utf8 and Utf8View columns as the same type.

To Reproduce

use datafusion::common::arrow::array::{ArrayRef, StringArray, StringViewArray};
use datafusion::common::arrow::record_batch::RecordBatch;
use datafusion::prelude::*;
use std::sync::Arc;

#[tokio::main]
async fn main() {
    let ctx = SessionContext::new();
    let df = ctx
        .read_batch(
            RecordBatch::try_from_iter([
                (
                    "utf8",
                    Arc::new(StringArray::from(vec!["a", "b"])) as ArrayRef,
                ),
                (
                    "utf8view",
                    Arc::new(StringViewArray::from(vec!["a", "b"])) as ArrayRef,
                ),
            ])
            .unwrap(),
        )
        .unwrap();
    df.select(vec![coalesce(vec![col("utf8"), col("utf8view")])])
        .unwrap()
        .collect()
        .await
        .unwrap();
}

Result:

thread 'main' panicked at src/main.rs:25:10:
called `Result::unwrap()` on an `Err` value: Plan("Execution error: User-defined coercion failed with Execution(\"Fail to find the coerced type, errors: Some(Execution(\\\"Expect to get struct but got Utf8\\\"))\") No function matches the given name and argument types 'coalesce(Utf8, Utf8View)'. You might need to add explicit type casts.\n\tCandidate functions:\n\tcoalesce(UserDefined)")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Expected behavior

No error.

Additional context

It worked fine in version 42.2.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