Skip to content

Comments

feat: Cast numeric (non int) to timestamp#3559

Open
coderfender wants to merge 4 commits intoapache:mainfrom
coderfender:cast_float_to_timestamp
Open

feat: Cast numeric (non int) to timestamp#3559
coderfender wants to merge 4 commits intoapache:mainfrom
coderfender:cast_float_to_timestamp

Conversation

@coderfender
Copy link
Contributor

@coderfender coderfender commented Feb 20, 2026

Which issue does this PR close?

Closes ##3560 .

Rationale for this change

Adding support for further more native cast support.

  1. Float / Double cast to Timestamp (with ANSI support)
  2. DecimalType -> Timestamp cast (with ANSI support)
  3. Boolean -> Timestamp cast

This should more or less close out the cast matrix in terms of support (barring other not planned casts such as Timestamp -> Int etc)

What changes are included in this PR?

How are these changes tested?

  1. Enabled unit tests in CometCastSuite.scala and added new ones (along with benchmarking scripts) on the rust side to test cast at all Eval Modes

@coderfender coderfender force-pushed the cast_float_to_timestamp branch from 41393a5 to 5aa49b0 Compare February 20, 2026 21:09
@coderfender coderfender changed the title feat: Cast non numeric to timestamp feat: Cast numeric (non ints) to timestamp Feb 20, 2026
@coderfender coderfender changed the title feat: Cast numeric (non ints) to timestamp feat: Cast numeric (non int) to timestamp Feb 20, 2026
@coderfender coderfender force-pushed the cast_float_to_timestamp branch from 5aa49b0 to 88e0c83 Compare February 21, 2026 00:42
* Uses except (difference) to find differences without using collect()
* Checks cometDF and sparkDF including schemas
*/
protected def assertDataFrameEquals(
Copy link
Contributor Author

@coderfender coderfender Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my recent PR , I had to cast back the generated I had to resort to this route because we have no native comet support from Timestamp -> Float causing operator / native comet check assertion failures . I tried casting back to String and Long either the cast is incompatible or unsupported on native side

withTable("t1") {
generateDoubles().write.saveAsTable("t1")
val df = spark.sql("select a, cast(a as timestamp) from t1")
assertDataFrameEquals(df)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using assertDataFrameEquals instead of castTest means that we no longer have the ANSI and try_cast testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately that is true. But I could create a follow up to try and handle ANSI errors

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comet currently has the correct ANSI behavior because it falls back to Spark. I don't think we should merge this PR until we have confirmed that removing the fallback isn't introducing any correctness issues.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I totally agree that. I am working on introducing try and ANSI behavior to 'assertDataFrameEquals' method to make sure we don't skip any test case

@coderfender coderfender force-pushed the cast_float_to_timestamp branch from bd49514 to 4d3a6a3 Compare February 24, 2026 20:37
@coderfender
Copy link
Contributor Author

@andygrove I moved the 'assertDataFrameEquals' inside cast test to leverage existing Try and ANSI checks . This should help us gain confidence with native code and perhaps merge it

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.

2 participants