date_format FE/BE nullability mismatch: FE marks result non-nullable but BE can return NULL

Open Beginner friendly
#65,917 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
java, sql
Domain
backend, databases

Research direction

Start by locating the nereids date_format scalar function and its PropagateNullable declaration, then compare it with str_to_date and the AlwaysNullable interface javadoc mentioned in the issue. Done means FE treats date_format as nullable, matching the BE behavior and the documented AlwaysNullable treatment.

Written by the indexing model from the issue text.

Description

Description

The nereids date_format scalar function declares its nullability via PropagateNullable, so FE infers the result as non-nullable whenever both inputs are non-nullable. However, the BE implementation can return NULL for non-null input (e.g. when the format string is invalid or an edge-case value cannot be formatted), so FE's inferred nullability is wrong and mismatches BE.

This causes incorrect nullability metadata to be propagated through the query plan, which can lead to wrong results or crashes when BE actually produces NULLs for a column FE believes is non-nullable.

How to reproduce
-- FE infers the result as non-nullable (both args non-null), but BE may
-- return NULL for problematic inputs.
SELECT date_format(dt, '%Y-%m-%d') FROM t;

When dt is non-nullable but a row's value/format triggers a NULL result in BE, the mismatch between FE's non-nullable metadata and BE's actual NULL output can cause incorrect behavior.

Expected behavior

date_format should always be treated as nullable by FE, matching BE — the same treatment already given to the sibling str_to_date function (which uses AlwaysNullable), and as documented in the AlwaysNullable interface javadoc which lists date_format as an example.

Dominant language
Java
Stars
16k
Forks
4k
Avg merge
2d 12h
Merged PRs (30d)
569

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/doris

All issues in apache/doris

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.