Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(spark, bigquery): Add support for UNIX_SECONDS(...) #4350

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

VaggelisD
Copy link
Collaborator

BigQuery and Spark3/Databricks support UNIX_SECONDS(expr) which returns the number of seconds since 1970-01-01 00:00:00 UTC:

bigquery> SELECT UNIX_SECONDS(TIMESTAMP "2008-12-25 15:30:00+00") AS seconds;
seconds
1230219000

spark-sql (default)> SELECT UNIX_SECONDS(TIMESTAMP "2008-12-25 15:30:00+00") AS seconds;
seconds
1230219000

This PR adds exp.UnixSeconds to enable seamless parsing as well as transpiles the newly added node to DuckDB & Snowflake by utilizing exp.TimestampDiff at a SECOND granularity:

duckdb> SELECT DATE_DIFF('SECONDS', CAST('1970-01-01 00:00:00+00' AS TIMESTAMPTZ), '2008-12-25 15:30:00+00') AS seconds;
┌────────────┐
│  seconds   │
│   int64    │
├────────────┤
│ 1230219000 │
└────────────┘

snowflake> SELECT TIMESTAMPDIFF(SECONDS, CAST('1970-01-01 00:00:00+00' AS TIMESTAMPTZ), '2008-12-25 15:30:00+00') AS seconds;
1230219000

Docs

BQ | Spark3 | Databricks

@georgesittas georgesittas merged commit 87ab8fe into main Nov 5, 2024
6 checks passed
@georgesittas georgesittas deleted the vaggelisd/unix_seconds branch November 5, 2024 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants