Skip to content

Add coercion support for NULL literals #185

Closed

Description

@alamb

Note: migrated from original JIRA: https://issues.apache.org/jira/browse/ARROW-11851

As we observed in apache/arrow#9565 (comment) datafusion won't coerce null literals, forcing strange syntax such as:

rpad('hi', CAST(NULL AS INT), 'xy')

We should add automatic coercion logic from the null literal to any type and this expression should work just fine (produce a NULL output)

rpad('hi', NULL, 'xy')

Activity

  1. alamb commented on Apr 26, 2021

    @alamb
    ContributorAuthor

    Comment from Mike Seddon(MikeSeddonAU) @ 2021-03-03T21:52:10.241+0000:

    [~alamb] Previously I implemented the Null=UTF8 type based on the behavior of Postgres not Spark - because the Spark implementation comes with a lot of side effects like the fact that Parquet does not support the `NullType`. We can revisit.

    Comment from Andrew Lamb(alamb) @ 2021-03-04T19:29:54.556+0000:

    Makes sense to me
  2. alamb commented on Nov 14, 2022

    @alamb
    ContributorAuthor

    This appears to work just fine now:

    ❯ select cast(null as int);
    +------+
    | NULL |
    +------+
    |      |
    +------+
    1 row in set. Query took 0.033 seconds.
    

    🎉

  3. added a commit that references this issue on Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions