Skip to content

type coercion error in clickbench50 query #19809

Closed

Description

@askalt

Describe the bug

Extended clickbench query (benchmarks/queries/clickbench/extended/q6.sql) plan is failed with the error:

Internal error: Expect TypeSignatureClass::Native(LogicalType(Native(String), String)) but received NativeType::Binary, DataType: BinaryView.

To Reproduce

Run datafusion-cli:

> CREATE EXTERNAL TABLE hits STORED AS PARQUET LOCATION "../benchmarks/data/hits_partitioned"

> SELECT COUNT(*) AS ShareCount FROM hits WHERE "IsMobile" = 1 AND "MobilePhoneModel" LIKE 'iPhone%' AND "SocialAction" = 'share' AND "SocialSourceNetworkID" IN (5, 12) AND "ClientTimeZone" BETWEEN -5 AND 5 AND regexp_match("Referer", '\/campaign\/(spring|summer)_promo') IS NOT NULL AND CASE WHEN split_part(split_part("URL", 'resolution=', 2), '&', 1) ~ '^\d+$' THEN split_part(split_part("URL", 'resolution=', 2), '&', 1)::INT ELSE 0 END > 1920 AND levenshtein(CAST("UTMSource" AS STRING), CAST("UTMCampaign" AS STRING)) < 3;

type_coercion
caused by
Internal error: Expect TypeSignatureClass::Native(LogicalType(Native(String), String)) but received NativeType::Binary, DataType: BinaryView.
This issue was likely caused by a bug in DataFusion's code. Please help us to resolve this by filing a bug report in our issue tracker: https://github.com/apache/datafusion/issues
$ 

Expected behavior

Query is planned successfully.

Activity

  1. added theissue type on Jan 14, 2026
  2. askalt commented on Jan 14, 2026

    @askalt
    ContributorAuthor

    Reduced example:

    > create table t (b bytea);
    
    > select count(*) from t where split_part(b, 'resolution=', 2)::INT > 0;
    
    type_coercion
    caused by
    Internal error: Expect TypeSignatureClass::Native(LogicalType(Native(String), String)) but received NativeType::Binary, DataType: Binary.
    This issue was likely caused by a bug in DataFusion's code. Please help us to resolve this by filing a bug report in our issue tracker: https://github.com/apache/datafusion/issues
    
  3. changed the title [-]type coercion error on clickbench50 query[/-] [+]type coercion error in clickbench50 query[/+] on Jan 14, 2026
  4. lemorage commented on Jan 14, 2026

    @lemorage
    Contributor

    take

  5. askalt commented on Jan 14, 2026

    @askalt
    ContributorAuthor

    It seems, binary_as_string configuration fixes:

    set datafusion.execution.parquet.binary_as_string = true

    Because SplitPartFunc explicitly wants string:

    impl SplitPartFunc {
        pub fn new() -> Self {
            Self {
                signature: Signature::coercible(
                    vec![
                        Coercion::new_exact(TypeSignatureClass::Native(logical_string())),
                        Coercion::new_exact(TypeSignatureClass::Native(logical_string())),
                        Coercion::new_implicit(
                            TypeSignatureClass::Native(logical_int64()),
                            vec![TypeSignatureClass::Integer],
                            NativeType::Int64,
                        ),
                    ],
                    Volatility::Immutable,
                ),
            }
        }
    }

    The question is: "why did it even work at one time without this setting?". Investigated that it worked before refactoring
    1ce4b51

    There was cast to utf-8 in the plan:

    split_part(CAST(hits.URL AS Utf8), CAST(Utf8("resolution=") AS Utf8View), Int64(2))
    

    So maybe we should set this configuration by default for query-planner benchmark.

  6. askalt commented on Jan 14, 2026

    @askalt
    ContributorAuthor

    Note: it causes query-planner benchmark fail:

    #19792 (comment)

  7. lemorage commented on Jan 14, 2026

    @lemorage
    Contributor

    Maybe it would be better to add the implicit coercion in SplitPartFunc::new() there?

  8. askalt commented on Jan 14, 2026

    @askalt
    ContributorAuthor

    Maybe it would be better to add the implicit coercion in SplitPartFunc::new() there?

    Sounds good to me.

  9. alamb commented on Jan 15, 2026

    @alamb
    Contributor

    BTW you can reproduce the problem using cargo bench as well

    cargo bench --profile=dev --bench sql_planner -- q50
    andrewlamb@Andrews-MacBook-Pro-3:~/Software/datafusion$ cargo bench --profile=dev --bench sql_planner -- q50
        Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.20s
         Running benches/sql_planner.rs (target/debug/deps/sql_planner-5e0f5af2fea8f56d)
    Gnuplot not found, using plotters backend
    Benchmarking physical_plan_clickbench_q50: Warming up for 3.0000 s
    thread 'main' (38326073) panicked at datafusion/core/benches/sql_planner.rs:62:14:
    called `Result::unwrap()` on an `Err` value: Context("type_coercion", Internal("Expect TypeSignatureClass::Native(LogicalType(Native(String), String)) but received NativeType::Binary, DataType: BinaryView"))
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    
    error: bench failed, to rerun pass `-p datafusion --bench sql_planner`
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions