Get.sql 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. /* syntax version 1 */
  2. $check = ($arg) -> {
  3. return <|
  4. ryear: DateTime::GetYear($arg),
  5. rdayofyear: DateTime::GetDayOfYear($arg),
  6. rmonth: DateTime::GetMonth($arg),
  7. rmonthname: DateTime::GetMonthName($arg),
  8. rweekofyear: DateTime::GetWeekOfYear($arg),
  9. rweekofyeariso8601: DateTime::GetWeekOfYearIso8601($arg),
  10. rdayofmonth: DateTime::GetDayOfMonth($arg),
  11. rdayofweek: DateTime::GetDayOfWeek($arg),
  12. rdayofweekname: DateTime::GetDayOfWeekName($arg),
  13. rhour: DateTime::GetHour($arg),
  14. rminute: DateTime::GetMinute($arg),
  15. rsecond: DateTime::GetSecond($arg),
  16. rmsec: DateTime::GetMillisecondOfSecond($arg),
  17. rusec: DateTime::GetMicrosecondOfSecond($arg),
  18. rtz: DateTime::GetTimezoneId($arg),
  19. rtzname: DateTime::GetTimezoneName($arg),
  20. |>
  21. };
  22. $typeDispatcher = ($row) -> {
  23. $tm = $row.tm;
  24. return <|
  25. explicit: $check(DateTime::Split($tm)),
  26. implicit: $check($tm),
  27. |>;
  28. };
  29. $input = SELECT CAST(ftztimestamp as TzTimestamp) as tm FROM Input;
  30. PROCESS $input USING $typeDispatcher(TableRow());