-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-46380][SQL]Replace current time/date prior to evaluating inline table expressions. #44316
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 10 commits
6757409
ed33d5e
0127596
5e24fe1
f019b9c
0f5fd12
2220ee8
ba321fc
9f46333
971e3cc
15a8bab
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 |
|---|---|---|
|
|
@@ -131,6 +131,21 @@ case class UnresolvedInlineTable( | |
| lazy val expressionsResolved: Boolean = rows.forall(_.forall(_.resolved)) | ||
| } | ||
|
|
||
| /** | ||
| * An resolved inline table that holds all the expressions that were checked for | ||
| * the right shape and common data types. | ||
| * This is a preparation step for [[org.apache.spark.sql.catalyst.optimizer.EvalInlineTables]] which | ||
| * will produce a [[org.apache.spark.sql.catalyst.plans.logical.LocalRelation]] | ||
| * for this inline table. | ||
| * | ||
| * @param output list of column attributes | ||
| * @param rows expressions for the data rows | ||
| */ | ||
| case class ResolvedInlineTable(rows: Seq[Seq[Expression]], output: Seq[Attribute]) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dbatomic After review this PR again. I'm sorry for the above comment. |
||
| extends LeafNode { | ||
| final override val nodePatterns: Seq[TreePattern] = Seq(INLINE_TABLE_EVAL) | ||
| } | ||
|
|
||
| /** | ||
| * A table-valued function, e.g. | ||
| * {{{ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,3 +60,9 @@ select * from values (timestamp('1991-12-06 00:00:00.0'), array(timestamp('1991- | |
| select * from values (try_add(5, 0)); | ||
| select * from values (try_divide(5, 0)); | ||
| select * from values (10 + try_divide(5, 0)); | ||
|
|
||
| -- now() should be kept as tempResolved inline expression. | ||
| select count(distinct ct) from values now(), now(), now() as data(ct); | ||
|
|
||
| -- current_timestamp() should be kept as tempResolved inline expression. | ||
| select count(distinct ct) from values current_timestamp(), current_timestamp() as data(ct); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we add tests mixed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's testing the correct value using count distinct. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -271,3 +271,19 @@ select * from values (10 + try_divide(5, 0)) | |
| struct<col1:double> | ||
| -- !query output | ||
| NULL | ||
|
|
||
|
|
||
| -- !query | ||
| select count(distinct ct) from values now(), now(), now() as data(ct) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can add a test for |
||
| -- !query schema | ||
| struct<count(DISTINCT ct):bigint> | ||
| -- !query output | ||
| 1 | ||
|
|
||
|
|
||
| -- !query | ||
| select count(distinct ct) from values current_timestamp(), current_timestamp() as data(ct) | ||
| -- !query schema | ||
| struct<count(DISTINCT ct):bigint> | ||
| -- !query output | ||
| 1 | ||
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.
It seems we only need theSeq[Expression]here.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.
it's a table (rows X columns)
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.
I know that. You means the X columns for each row is different?
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.
I got it now. Thank you!