Exemple #1
0
 def get_seconds(scol):
     hour_scol = SF.date_part("HOUR", scol)
     minute_scol = SF.date_part("MINUTE", scol)
     second_scol = SF.date_part("SECOND", scol)
     return (F.when(
         hour_scol < 0,
         SECONDS_PER_DAY + hour_scol * SECONDS_PER_HOUR,
     ).otherwise(hour_scol * SECONDS_PER_HOUR) + F.when(
         minute_scol < 0,
         SECONDS_PER_DAY + minute_scol * SECONDS_PER_MINUTE,
     ).otherwise(minute_scol * SECONDS_PER_MINUTE) + F.when(
         second_scol < 0,
         SECONDS_PER_DAY + second_scol,
     ).otherwise(second_scol)).cast("int")
Exemple #2
0
 def get_microseconds(scol):
     second_scol = SF.date_part("SECOND", scol)
     return ((F.when(
         (second_scol >= 0) & (second_scol < 1),
         second_scol,
     ).when(second_scol < 0, 1 + second_scol).otherwise(0)) *
             MICROS_PER_SECOND).cast("int")