@@ -851,41 +851,43 @@ public static long millisecondFromInterval(@SqlType(StandardTypes.INTERVAL_DAY_T
851851 @ Description ("second of the minute of the given timestamp" )
852852 @ ScalarFunction ("second" )
853853 @ SqlType (StandardTypes .BIGINT )
854- public static long secondFromTimestamp (@ SqlType (StandardTypes .TIMESTAMP ) long timestamp )
854+ public static long secondFromTimestamp (SqlFunctionProperties properties , @ SqlType (StandardTypes .TIMESTAMP ) long timestamp )
855855 {
856- // No need to check isLegacyTimestamp:
857- // * Under legacy semantics, the session zone matters. But a zone always has offset of whole minutes.
858- // * Under new semantics, timestamp is agnostic to the session zone.
859- return SECOND_OF_MINUTE .get (timestamp );
856+ if (properties .isLegacyTimestamp ()) {
857+ return getChronology (properties .getTimeZoneKey ()).secondOfMinute ().get (timestamp );
858+ }
859+ else {
860+ return SECOND_OF_MINUTE .get (timestamp );
861+ }
860862 }
861863
862864 @ Description ("second of the minute of the given timestamp" )
863865 @ ScalarFunction ("second" )
864866 @ SqlType (StandardTypes .BIGINT )
865867 public static long secondFromTimestampWithTimeZone (@ SqlType (StandardTypes .TIMESTAMP_WITH_TIME_ZONE ) long timestampWithTimeZone )
866868 {
867- // No need to check the associated zone here. A zone always has offset of whole minutes.
868- return SECOND_OF_MINUTE .get (unpackMillisUtc (timestampWithTimeZone ));
869+ return unpackChronology (timestampWithTimeZone ).secondOfMinute ().get (unpackMillisUtc (timestampWithTimeZone ));
869870 }
870871
871872 @ Description ("second of the minute of the given time" )
872873 @ ScalarFunction ("second" )
873874 @ SqlType (StandardTypes .BIGINT )
874- public static long secondFromTime (@ SqlType (StandardTypes .TIME ) long time )
875+ public static long secondFromTime (SqlFunctionProperties properties , @ SqlType (StandardTypes .TIME ) long time )
875876 {
876- // No need to check isLegacyTimestamp:
877- // * Under legacy semantics, the session zone matters. But a zone always has offset of whole minutes.
878- // * Under new semantics, time is agnostic to the session zone.
879- return SECOND_OF_MINUTE .get (time );
877+ if (properties .isLegacyTimestamp ()) {
878+ return getChronology (properties .getTimeZoneKey ()).secondOfMinute ().get (time );
879+ }
880+ else {
881+ return SECOND_OF_MINUTE .get (time );
882+ }
880883 }
881884
882885 @ Description ("second of the minute of the given time" )
883886 @ ScalarFunction ("second" )
884887 @ SqlType (StandardTypes .BIGINT )
885- public static long secondFromTimeWithTimeZone (@ SqlType (StandardTypes .TIME_WITH_TIME_ZONE ) long time )
888+ public static long secondFromTimeWithTimeZone (@ SqlType (StandardTypes .TIME_WITH_TIME_ZONE ) long timeWithTimeZone )
886889 {
887- // No need to check the associated zone here. A zone always has offset of whole minutes.
888- return SECOND_OF_MINUTE .get (unpackMillisUtc (time ));
890+ return unpackChronology (timeWithTimeZone ).secondOfMinute ().get (unpackMillisUtc (timeWithTimeZone ));
889891 }
890892
891893 @ Description ("second of the minute of the given interval" )
0 commit comments