Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/19811#discussion_r156924217
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala
---
@@ -484,18 +484,17 @@ case class WeekOfYear(child: Expression) extends
UnaryExpression with ImplicitCa
override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
nullSafeCodeGen(ctx, ev, time => {
val cal = classOf[Calendar].getName
- val c = ctx.freshName("cal")
val dtu = DateTimeUtils.getClass.getName.stripSuffix("$")
- ctx.addMutableState(cal, c,
+ val c = ctx.addMutableState(cal, "cal", v =>
s"""
- $c = $cal.getInstance($dtu.getTimeZone("UTC"));
- $c.setFirstDayOfWeek($cal.MONDAY);
- $c.setMinimalDaysInFirstWeek(4);
+ |$v = $cal.getInstance($dtu.getTimeZone("UTC"));
+ |$v.setFirstDayOfWeek($cal.MONDAY);
+ |$v.setMinimalDaysInFirstWeek(4);
""")
--- End diff --
you forget the `stripMargin`, now the `|` will be in the code and fail to
compile...
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]