-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-33627][SQL] Add new function UNIX_SECONDS, UNIX_MILLIS and UNIX_MICROS #30566
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
Changes from 6 commits
80d06c3
0b31348
35ef5d2
45495c7
82ba97b
f5e4b53
270aa95
46c8651
025fdd2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| <!-- Automatically generated by ExpressionsSchemaSuite --> | ||
| ## Summary | ||
| - Number of queries: 342 | ||
| - Number of queries: 345 | ||
| - Number of expressions that missing example: 13 | ||
| - Expressions missing examples: bigint,binary,boolean,date,decimal,double,float,int,smallint,string,timestamp,tinyint,window | ||
| ## Schema of Built-in Functions | ||
|
|
@@ -289,6 +289,9 @@ | |
| | org.apache.spark.sql.catalyst.expressions.UnaryMinus | negative | SELECT negative(1) | struct<negative(1):int> | | ||
| | org.apache.spark.sql.catalyst.expressions.UnaryPositive | positive | SELECT positive(1) | struct<(+ 1):int> | | ||
| | org.apache.spark.sql.catalyst.expressions.Unhex | unhex | SELECT decode(unhex('537061726B2053514C'), 'UTF-8') | struct<decode(unhex(537061726B2053514C), UTF-8):string> | | ||
| | org.apache.spark.sql.catalyst.expressions.UnixMicros | unix_micros | SELECT unix_micros(TIMESTAMP('1970-01-01 00:00:01')) | struct<unix_micros(CAST(1970-01-01 00:00:01 AS TIMESTAMP)):bigint> | | ||
| | org.apache.spark.sql.catalyst.expressions.UnixMillis | unix_millis | SELECT unix_millis(TIMESTAMP('1970-01-01 00:00:01')) | struct<unix_millis(CAST(1970-01-01 00:00:01 AS TIMESTAMP)):bigint> | | ||
| | org.apache.spark.sql.catalyst.expressions.UnixSeconds | unix_seconds | SELECT unix_seconds(TIMESTAMP('1970-01-01 00:00:01')) | struct<unix_seconds(CAST(1970-01-01 00:00:01 AS TIMESTAMP)):bigint> | | ||
|
||
| | org.apache.spark.sql.catalyst.expressions.UnixTimestamp | unix_timestamp | SELECT unix_timestamp() | struct<unix_timestamp(current_timestamp(), yyyy-MM-dd HH:mm:ss):bigint> | | ||
| | org.apache.spark.sql.catalyst.expressions.Upper | ucase | SELECT ucase('SparkSql') | struct<ucase(SparkSql):string> | | ||
| | org.apache.spark.sql.catalyst.expressions.Upper | upper | SELECT upper('SparkSql') | struct<upper(SparkSql):string> | | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,10 @@ select TIMESTAMP_MILLIS(-92233720368547758); | |
| select TIMESTAMP_SECONDS(0.1234567); | ||
| -- truncation is OK for float/double | ||
| select TIMESTAMP_SECONDS(0.1234567d), TIMESTAMP_SECONDS(FLOAT(0.1234567)); | ||
| -- UNIX_SECONDS, UNIX_MILLISECONDS and UNIX_MICROSECONDS | ||
| select UNIX_SECONDS(TIMESTAMP('2020-12-01 14:30:08')), UNIX_SECONDS(TIMESTAMP('2020-12-01 14:30:08.999999')), UNIX_SECONDS(null); | ||
| select UNIX_MILLIS(TIMESTAMP('2020-12-01 14:30:08')), UNIX_MILLIS(TIMESTAMP('2020-12-01 14:30:08.999999')), UNIX_MILLIS(null); | ||
| select UNIX_MICROS(TIMESTAMP('2020-12-01 14:30:08')), UNIX_MICROS(TIMESTAMP('2020-12-01 14:30:08.999999')), UNIX_MICROS(null); | ||
|
||
|
|
||
| -- [SPARK-16836] current_date and current_timestamp literals | ||
| select current_date = current_date(), current_timestamp = current_timestamp(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -151,6 +151,9 @@ class ExpressionInfoSuite extends SparkFunSuite with SharedSparkSession { | |
| "org.apache.spark.sql.catalyst.expressions.CurrentTimestamp", | ||
| "org.apache.spark.sql.catalyst.expressions.CurrentTimeZone", | ||
| "org.apache.spark.sql.catalyst.expressions.Now", | ||
| "org.apache.spark.sql.catalyst.expressions.UnixSeconds", | ||
| "org.apache.spark.sql.catalyst.expressions.UnixMillis", | ||
| "org.apache.spark.sql.catalyst.expressions.UnixMicros", | ||
|
||
| // Random output without a seed | ||
| "org.apache.spark.sql.catalyst.expressions.Rand", | ||
| "org.apache.spark.sql.catalyst.expressions.Randn", | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's also test null and negative input (that truncates)