Skip to content

try_make_timestamp returns wrong values for invalid inputs instead of NULL #4554

@andygrove

Description

@andygrove

Bug Report

When try_make_timestamp is called with column arguments containing invalid date/time components (e.g., month=13, day=32, hour=25), Comet runs the query natively (CometProject) but returns an incorrect timestamp value instead of NULL.

Spark's try_make_timestamp rewrites to MakeTimestamp(failOnError=false), which should return NULL instead of throwing an exception for invalid inputs.

Reproduction

CREATE TABLE test_try_make_ts(y int, mo int, d int, h int, mi int, s decimal(8,6)) USING parquet;
INSERT INTO test_try_make_ts VALUES (2024, 13, 1, 0, 0, 0.0), (2024, 6, 32, 0, 0, 0.0), (2024, 6, 15, 25, 0, 0.0);
SELECT try_make_timestamp(y, mo, d, h, mi, s) FROM test_try_make_ts;

Expected

All three rows should return NULL (invalid components).

Actual (Comet)

Returns garbage timestamp values (e.g., 1969-12-31 15:59:59.999999) for the invalid rows.

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    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