Skip to content

test: add SQL file tests for try_to_date, try_to_timestamp, try_make_timestamp#4555

Open
andygrove wants to merge 2 commits into
apache:mainfrom
andygrove:test-try-datetime-coverage
Open

test: add SQL file tests for try_to_date, try_to_timestamp, try_make_timestamp#4555
andygrove wants to merge 2 commits into
apache:mainfrom
andygrove:test-try-datetime-coverage

Conversation

@andygrove
Copy link
Copy Markdown
Member

Which issue does this PR close?

N/A. This adds test coverage only. Surfaces and references #4554.

Rationale for this change

The try_* datetime parsing/constructor functions (try_to_date, try_to_timestamp, try_make_timestamp) had no Comet test coverage. They are RuntimeReplaceable and lower to Cast / GetTimestamp / MakeTimestamp, whose non-try forms Comet already accelerates, so it was worth checking empirically whether the try_ forms are accelerated too. The result is mixed and worth pinning down with tests.

What changes are included in this PR?

Adds spark/src/test/resources/sql-tests/expressions/datetime/try_datetime.sql, covering column and literal arguments (including invalid inputs that exercise the NULL-on-error path) and NULLs. Empirical findings, encoded in the query modes:

  • try_to_date and try_to_timestamp currently fall back to Spark, so their queries use query spark_answer_only (result correctness is still validated against Spark).
  • try_make_timestamp runs natively for valid inputs, but returns wrong values instead of NULL for out-of-range components (failOnError = false is not honoured natively). Valid-input queries use query spark_answer_only; invalid-input queries use query ignore(...) referencing the bug, try_make_timestamp returns wrong values for invalid inputs instead of NULL #4554.

When #4554 is fixed and the try_to_* fallback is addressed, these queries can be promoted to the default query mode to assert native execution.

How are these changes tested?

This PR is test-only. The file runs under CometSqlFileTestSuite, executing each query through both Spark and Comet and comparing results. Verified locally:

./mvnw test -Dsuites="org.apache.comet.CometSqlFileTestSuite try_datetime" -Dtest=none

Result: the discovered test file passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant