MaxGekk commented on code in PR #40126:
URL: https://github.com/apache/spark/pull/40126#discussion_r1119846624
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala:
##########
@@ -669,17 +669,26 @@ class AstBuilder extends SqlBaseParserBaseVisitor[AnyRef]
with SQLConfHelper wit
)
}
+ private def getAliasFunc(alias: => String): Option[Expression => String] = {
+ if (conf.getConf(SQLConf.STABLE_DERIVED_COLUMN_ALIAS_ENABLED)) {
+ Some(_ => alias)
+ } else {
+ None
+ }
+ }
+
override def visitNamedExpressionSeq(
- ctx: NamedExpressionSeqContext): Seq[Expression] = {
+ ctx: NamedExpressionSeqContext): Seq[(Expression, Option[Expression =>
String])] = {
Option(ctx).toSeq
.flatMap(_.namedExpression.asScala)
- .map(typedVisit[Expression])
+ .map(ctx => (typedVisit[Expression](ctx),
getAliasFunc(toExprAlias(ctx))))
Review Comment:
Just in case, this function handle not only named expressions but others
too. For example:
```sql
select 1;
```
is handled by `visitNamedExpressionSeq()` but not by `visitExpressionSeq()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]