Skip to content

Discuss unifying NVL and IFNULL coercion with COALESCE #26639

Open

Description

@1fanwang

Is your feature request related to a problem or challenge?

NVL and IFNULL can choose a different result type from COALESCE for the same arguments. The compatibility-preserving fix in #25964 retains their existing rules for boolean, integer, float and string arguments while fixing decimal and temporal types.

The review discussion reports that NVL(Int64, UInt64) chooses Float32, whereas COALESCE chooses Decimal128(20,0), and suggests using COALESCE's rules throughout. This issue tracks the behavior decision requested in #25964 (comment).

Describe the solution you'd like

Decide whether NVL and IFNULL should use COALESCE's common-type resolution for every argument pair. That would remove the separate coercion rule and avoid the reported wide-integer precision loss.

The compatibility cost needs agreement first: existing calls such as IFNULL(int_col, false) currently plan with a string result, but COALESCE rejects that combination. If the behavior changes, document the affected combinations and migration in the upgrade guide, with regression coverage for both result types and values.

Describe alternatives you've considered

Keep the compatibility-preserving rules from #25964. This avoids rejecting existing queries but leaves two coercion paths to maintain.

Additional context

The current split is implemented in NVLFunc::coerce_types. This is a follow-up discussion, not a request to broaden that PR or duplicate #25947.

Willingness to contribute

I would like to contribute to this feature, but request guidance from the DataFusion community.

Activity

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