Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions spark/src/main/scala/org/apache/comet/serde/aggregates.scala
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,6 @@ object CometAverage extends CometAggregateExpressionSerde[Average] {

object CometSum extends CometAggregateExpressionSerde[Sum] {

override def getIncompatibleReasons(): Seq[String] = Seq("Falls back to Spark in ANSI mode.")

Comment thread
coderfender marked this conversation as resolved.
override def convert(
aggExpr: AggregateExpression,
sum: Sum,
Expand Down
2 changes: 1 addition & 1 deletion spark/src/main/scala/org/apache/comet/serde/strings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import org.apache.comet.serde.QueryPlanSerde.{createBinaryExpr, exprToProtoInter

object CometStringRepeat extends CometExpressionSerde[StringRepeat] {

override def getCompatibleNotes(): Seq[String] = Seq(
override def getIncompatibleReasons(): Seq[String] = Seq(
Comment thread
coderfender marked this conversation as resolved.
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.

getIncompatibleReasons needs to be removed now that this issue has been fixed in #4017

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.

Actually that was the wrong issue ... why does this PR rename this method? There is no getSupportLevel so this expression is not marked as incompatible

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.

True ! Thank you for pointing this out. I fixed it in the latest commit

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.

some comments got lost I think due to GitHub outages ... I don't understand why this PR is removing getCompatibleNotes and adding getIncompatibleReasons

"A negative argument for the number of times to repeat throws an exception" +
" instead of returning an empty string as Spark does")

Expand Down
44 changes: 30 additions & 14 deletions spark/src/main/scala/org/apache/comet/serde/unixtime.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,27 @@ import org.apache.comet.serde.QueryPlanSerde.{exprToProtoInternal, optExprWithIn
// https://github.com/apache/datafusion/issues/16594
object CometFromUnixTime extends CometExpressionSerde[FromUnixTime] {

override def getUnsupportedReasons(): Seq[String] = Seq(
"Only supports the default datetime format pattern `yyyy-MM-dd HH:mm:ss`")

override def getIncompatibleReasons(): Seq[String] = Seq(
"Only supports the default datetime format pattern `yyyy-MM-dd HH:mm:ss`." +
" DataFusion's valid timestamp range differs from Spark" +
"DataFusion's valid timestamp range differs from Spark" +
" (https://github.com/apache/datafusion/issues/16594)")

override def getSupportLevel(expr: FromUnixTime): SupportLevel = Incompatible(None)
override def getSupportLevel(expr: FromUnixTime): SupportLevel = {
expr.format match {
case Literal(fmt, _) =>
val formatStr = fmt.toString
Comment thread
coderfender marked this conversation as resolved.
val defaultPattern = TimestampFormatter.defaultPattern
if (formatStr == defaultPattern) {
Incompatible(None)
} else {
Comment thread
coderfender marked this conversation as resolved.
Unsupported(Some(s"Datetime pattern format: $formatStr is unsupported"))
}
case _ =>
Unsupported(Some("Datetime pattern format is unsupported"))
Comment thread
coderfender marked this conversation as resolved.
Outdated
}
Comment thread
coderfender marked this conversation as resolved.
}

override def convert(
expr: FromUnixTime,
Expand All @@ -48,17 +63,18 @@ object CometFromUnixTime extends CometExpressionSerde[FromUnixTime] {
val formatExpr = exprToProtoInternal(Literal("%Y-%m-%d %H:%M:%S"), inputs, binding)
val timeZone = exprToProtoInternal(Literal(expr.timeZoneId.orNull), inputs, binding)

if (expr.format != Literal(TimestampFormatter.defaultPattern)) {
withInfo(expr, "Datetime pattern format is unsupported")
None
} else if (secExpr.isDefined && formatExpr.isDefined) {
val timestampExpr =
scalarFunctionExprToProto("from_unixtime", Seq(secExpr, timeZone): _*)
val optExpr = scalarFunctionExprToProto("to_char", Seq(timestampExpr, formatExpr): _*)
optExprWithInfo(optExpr, expr, expr.sec, expr.format)
} else {
withInfo(expr, expr.sec, expr.format)
None
expr.format match {
case Literal(fmt, _) if fmt != null && fmt.toString != TimestampFormatter.defaultPattern =>
withInfo(expr, "Datetime pattern format is unsupported")
None
case _ if secExpr.isDefined && formatExpr.isDefined =>
val timestampExpr =
scalarFunctionExprToProto("from_unixtime", Seq(secExpr, timeZone): _*)
val optExpr = scalarFunctionExprToProto("to_char", Seq(timestampExpr, formatExpr): _*)
optExprWithInfo(optExpr, expr, expr.sec, expr.format)
Comment thread
coderfender marked this conversation as resolved.
Outdated
case _ =>
withInfo(expr, expr.sec, expr.format)
None
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ INSERT INTO test_from_unix_time VALUES (0), (1718451045), (-1), (NULL), (2147483
query expect_fallback(not fully compatible with Spark)
SELECT from_unixtime(t) FROM test_from_unix_time

query expect_fallback(not fully compatible with Spark)
query expect_fallback(Datetime pattern format: yyyy-MM-dd is unsupported)
SELECT from_unixtime(t, 'yyyy-MM-dd') FROM test_from_unix_time
Comment thread
coderfender marked this conversation as resolved.

-- literal arguments
query expect_fallback(not fully compatible with Spark)
SELECT from_unixtime(0)

query expect_fallback(not fully compatible with Spark)
query expect_fallback(Datetime pattern format: yyyy-MM-dd is unsupported)
SELECT from_unixtime(1718451045, 'yyyy-MM-dd')
Loading