daft.functions.to_utc_timestamp#
to_utc_timestamp #
to_utc_timestamp(expr: Expression, timezone: str) -> Expression
Interprets a wall-clock timestamp in the given timezone and returns the UTC instant.
Mirrors Spark's to_utc_timestamp. The input's wall-clock value is treated as local time in timezone and converted to the equivalent UTC instant, returned as a tz-naive Timestamp.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expr | Expression | A Timestamp expression whose wall-clock is interpreted in | required |
timezone | str | Source timezone name. | required |
Returns:
| Name | Type | Description |
|---|---|---|
Expression | Expression | A tz-naive Timestamp expression representing the UTC instant. |
Note
DST transition handling differs from Spark. When the local wall-clock falls in a non-existent gap (e.g. the spring-forward hour) or an ambiguous overlap (e.g. the fall-back hour), Daft raises a ValueError rather than silently picking a side. Spark instead advances past the gap and resolves ambiguity to the pre-transition offset. If you need Spark-compatible behavior, filter or pre-shift these inputs before calling.
Examples:
1 2 3 4 5 6 | |
[datetime.datetime(2017, 7, 14, 2, 40)] Source code in daft/functions/datetime.py
1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 | |