Skip to content
Closed
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ case class DateFormatClass(left: Expression, right: Expression, timeZoneId: Opti
val tz = ctx.addReferenceObj("timeZone", timeZone)
val locale = ctx.addReferenceObj("locale", Locale.US)
defineCodeGen(ctx, ev, (timestamp, format) => {
s"""UTF8String.fromString($tf.apply($format.toString(), $tz, $locale)
s"""UTF8String.fromString($tf$$.MODULE$$.apply($format.toString(), $tz, $locale)
Copy link
Contributor

Choose a reason for hiding this comment

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

is apply a special case? IIRC java can call methods in scala object, just like calling static methods.

Copy link
Member

Choose a reason for hiding this comment

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

The static methods are methods of the companion object, so yeah you need to access static methods like this in Java.

Copy link
Member

Choose a reason for hiding this comment

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

which is pretty annoying when you access to it in Python side via Py4J .. !!

.format($timestamp))"""
})
}
Expand Down Expand Up @@ -741,11 +741,11 @@ abstract class UnixTime
case StringType =>
val tz = ctx.addReferenceObj("timeZone", timeZone)
val locale = ctx.addReferenceObj("locale", Locale.US)
val dtu = TimestampFormatter.getClass.getName.stripSuffix("$")
val tf = TimestampFormatter.getClass.getName.stripSuffix("$")
nullSafeCodeGen(ctx, ev, (string, format) => {
s"""
try {
${ev.value} = $dtu.apply($format.toString(), $tz, $locale)
${ev.value} = $tf$$.MODULE$$.apply($format.toString(), $tz, $locale)
.parse($string.toString()) / 1000000L;
} catch (java.lang.IllegalArgumentException e) {
${ev.isNull} = true;
Expand Down