Skip to content

feat: Support Spark expression: make_dt_interval#4338

Open
YutaLin wants to merge 9 commits into
apache:mainfrom
YutaLin:3098_support_expression_make_dt_interval
Open

feat: Support Spark expression: make_dt_interval#4338
YutaLin wants to merge 9 commits into
apache:mainfrom
YutaLin:3098_support_expression_make_dt_interval

Conversation

@YutaLin
Copy link
Copy Markdown
Contributor

@YutaLin YutaLin commented May 15, 2026

Which issue does this PR close?

Closes #3098

Rationale for this change

Support expression make_dt_interval

What changes are included in this PR?

  • Support DateTimeIntervalType in QueryPlanSerd, serd.rs and types.proto
  • Leverage make_dt_interval from datafusion-spark, so update jni_api.rs, datatime.scala and QueryPlanSerd
  • Support duration(microsend) in ArrowType
  • Support null duration

How are these changes tested?

Add make_dt_interval sql and test in spark3.4/3.5/4.0

@YutaLin
Copy link
Copy Markdown
Contributor Author

YutaLin commented May 15, 2026

This patch also help #4150


object CometMakeDate extends CometScalarFunction[MakeDate]("make_date")

object CometMakeDTInterval extends CometScalarFunction[MakeDTInterval]("make_dt_interval")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you implement getSupportLevel and mark this as incompatible. Also, we need getIncompatReasons so we generate documentation.

My AI review helper tells me that Spark's IntervalUtils.makeDayTimeInterval uses Math.addExact / Math.multiplyExact and always throws on overflow:

  catch {
    case _: ArithmeticException =>
      throw QueryExecutionErrors.withoutSuggestionIntervalArithmeticOverflowError(context)
  }

The upstream SparkMakeDtInterval kernel uses checked_mul / checked_add and silently returns NULL on overflow. Inputs that throw INTERVAL_ARITHMETIC_OVERFLOW in Spark will
produce a NULL row in Comet.

Could you verify whether this is true or not? If it is then we can just mark it incompatible for now and file an upstream issue against the datafusion repo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi @andygrove
Thanks for the review! The statement is true, i've marked it incompatible and filed an issue.

YutaLin added 2 commits May 20, 2026 14:58
…sion_make_dt_interval

# Conflicts:
#	docs/source/user-guide/latest/expressions.md
#	native/core/src/execution/planner.rs
#	native/proto/src/proto/types.proto
#	spark/src/main/scala/org/apache/comet/serde/QueryPlanSerde.scala
#	spark/src/main/scala/org/apache/comet/serde/datetime.scala
#	spark/src/main/scala/org/apache/spark/sql/comet/util/Utils.scala
@YutaLin YutaLin requested a review from andygrove May 20, 2026 19:46
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.

[Feature] Support Spark expression: make_dt_interval

2 participants