Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Fix codegen
  • Loading branch information
mihailomilosevic2001 committed Oct 4, 2024
commit 093cfe4148402601e7bf759c15628a4ad394bb31
Original file line number Diff line number Diff line change
Expand Up @@ -1735,14 +1735,14 @@ case class DateAddInterval(
override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
val dtu = DateTimeUtils.getClass.getName.stripSuffix("$")
nullSafeCodeGen(ctx, ev, (sd, i) => if (ansiEnabled) {
s"""${ev.value} = $dtu.dateAddInterval($sd, $i);"""
s"""${ev.value} = $dtu.dateAddInterval($sd, $i, "$prettyName");"""
} else {
val zid = ctx.addReferenceObj("zoneId", zoneId, classOf[ZoneId].getName)
val startTs = ctx.freshName("startTs")
val resultTs = ctx.freshName("resultTs")
s"""
|if ($i.microseconds == 0) {
| ${ev.value} = $dtu.dateAddInterval($sd, $i);
| ${ev.value} = $dtu.dateAddInterval($sd, $i, "$prettyName");
|} else {
| long $startTs = $dtu.daysToMicros($sd, $zid);
| long $resultTs =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,8 @@ class DateExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
checkErrorInExpression[SparkIllegalArgumentException](
DateAddInterval(Literal(d), Literal(new CalendarInterval(1, 1, 25 * MICROS_PER_HOUR))),
"INVALID_PARAMETER_VALUE.INTERVAL_WITH_MICROSECONDS",
Map("ansiConfig" -> "\"spark.sql.ansi.enabled\""))
Map("parameter" -> "`interval`", "functionName" -> "`dateaddinterval`",
Copy link
Member

Choose a reason for hiding this comment

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

dateaddinterval there is no such function. That might confuse users. We could pass + instead, or create a error condition especially for the DateAddInterval expression (not sub-class of INVALID_PARAMETER_VALUE ).

"ansiConfig" -> "\"spark.sql.ansi.enabled\""))
}

withSQLConf((SQLConf.ANSI_ENABLED.key, "false")) {
Expand Down