Skip to content

[Bug] next_day does not throw under spark.sql.ansi.enabled=true #4449

@andygrove

Description

@andygrove

Describe the bug

next_day(date, dayOfWeek) returns NULL for an unrecognised dayOfWeek even when spark.sql.ansi.enabled=true, where Spark throws SparkIllegalArgumentException (3.5+) / IllegalArgumentException (3.4) wrapped via QueryExecutionErrors.ansiIllegalArgumentError.

The native impl is datafusion-spark::SparkNextDay, which always returns NULL on parse failure regardless of the ANSI flag.

Steps to reproduce

SET spark.sql.ansi.enabled=true;
SELECT next_day(date('2024-01-01'), 'NOT_A_DAY');
-- Spark: throws SparkIllegalArgumentException
-- Comet: returns NULL

Expected behavior

Match Spark: throw under ANSI; return NULL otherwise.

Additional context

Surfaced by the date/time audit (#4448). Reproducer captured as an ignored test in spark/src/test/resources/sql-tests/expressions/datetime/next_day.sql; remove the ignore(...) when this is fixed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions