Skip to content

Conversation

@jackwener
Copy link
Member

Which issue does this PR close?

Part of #3927 #2212

We should separate projection and alias-projection.

In fact, alias-projection is subqueryAlias, after this job, we can easy remove the alias in projection, and replace it with subqueryAlias

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added core Core DataFusion crate logical-expr Logical plan and expressions optimizer Optimizer rules sql SQL Planner labels Nov 16, 2022
Comment on lines +64 to +65
Projection: lineitem.l_orderkey, SUM(lineitem.l_extendedprice) AS price AS __value, alias=__sq_1
Projection: lineitem.l_orderkey
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problems like this indicate pushdown rule exist some bug.

@mingmwang
Copy link
Contributor

Do we need to support such kind of usage?

select ('aa1', 'aa2' as AA1) as B

@mingmwang
Copy link
Contributor

mingmwang commented Nov 18, 2022

BTW, below is the Spark SQL's plan

== Optimized Logical Plan ==
Project [[aa1,aa2] AS B#941145], Statistics(sizeInBytes=6.0 B)
+- OneRowRelation, Statistics(sizeInBytes=1.0 B)

== Physical Plan ==
*(1) Project [[aa1,aa2] AS B#941145]
+- *(1) Scan OneRowRelation[]

Another example;

select ('aa1', 'aa2' as AA1) as B, ('xx1', 'xx2' as BB1) as X

@jackwener
Copy link
Member Author

jackwener commented Nov 18, 2022

Spark doesn't have alias-projection. @mingmwang

We also can read sql standard 2003

Alias just contain

  • expr-alias (like: projection contain is expr)
  • table-ref-alias
select ('aa1', 'aa2' as AA1) as B

is 

Alias("B", Expr::List(aa1, Alias("AA1", aa2)))

Spark projection just contains Seq[NamedExpr] input

@jackwener
Copy link
Member Author

jackwener commented Nov 18, 2022

https://imgse.com/i/znjM9I

So we don't need projection keep alias, just expr::Alias is enough

@jackwener jackwener closed this Nov 18, 2022
@jackwener jackwener reopened this Nov 18, 2022
@mingmwang
Copy link
Contributor

https://imgse.com/i/znjM9I

So we don't need projection keep alias, just expr::Alias is enough

I am OK with removing alias from Projection. Let get some advices from other members also.

@jackwener
Copy link
Member Author

close. all job finish in #4333

@jackwener jackwener closed this Nov 23, 2022
@jackwener jackwener deleted the project_alias branch November 25, 2022 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core DataFusion crate logical-expr Logical plan and expressions optimizer Optimizer rules sql SQL Planner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants