Skip to content

physical-expr: Nullability of Literal is not determined by surrounding context #15394

Open
@rkrishn7

Description

@rkrishn7

Describe the bug

It was found in #15242 that the nullability of Literal is simply based on its scalar value and does not take its nullability in the input schema into account.

To Reproduce

This issue cannot be seen in the CLI, as it doesn't do any strict type checking of record batches when displaying results. However, it can be observed in SLTs where normalize::convert_batches ensures that each record batch's schema is the same as that of the first batch.

Take the following query for example:

select x, y, z from t3 union all by name select z, y, x, 'd' as zz from t3;

UNION is a case where record batch streams from each input will be merged into an output stream.

zz should be considered as nullable in the output schema because it is not found in the lhs. However, the current behavior is that record batches streamed from the rhs do not have zz as null because of the current implementation of PhysicalExpr::nullable for Literal.

Expected behavior

The nullability of Literal should be determined by its surrounding context and value, not only its value.

Additional context

No response

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