Github user tarekauel commented on a diff in the pull request: https://github.com/apache/spark/pull/7516#discussion_r34960308 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeFunctions.scala --- @@ -225,8 +229,8 @@ case class WeekOfYear(child: Expression) extends UnaryExpression with ImplicitCa nullSafeCodeGen(ctx, ev, (time) => { val cal = classOf[Calendar].getName val c = ctx.freshName("cal") + ctx.addMutableState(cal, c, s"""$cal.getInstance(java.util.TimeZone.getTimeZone("UTC"));""") s""" - $cal $c = $cal.getInstance(java.util.TimeZone.getTimeZone("UTC")); $c.setFirstDayOfWeek($cal.MONDAY); $c.setMinimalDaysInFirstWeek(4); --- End diff -- If we extend `CodeGenContext.addMutableState(javaName, variableName, initialValue)` to something like `CodeGenContext.addMutableState(javaName, variableName, initialValue, initialCode: Option[String] = None)` we could get grid of these two lines and allow more complex initialisations than a single method call. So far there is nothing to pass a more complex initialisation, is there? @cloud-fan I guess you have created the pr for `addMutableState`. Is there a opportunity to push the two lines to the initialisation?
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org