summaryrefslogtreecommitdiffstats
path: root/sqlglot/dataframe
diff options
context:
space:
mode:
Diffstat (limited to 'sqlglot/dataframe')
-rw-r--r--sqlglot/dataframe/sql/column.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/sqlglot/dataframe/sql/column.py b/sqlglot/dataframe/sql/column.py
index 3acf494..ca85376 100644
--- a/sqlglot/dataframe/sql/column.py
+++ b/sqlglot/dataframe/sql/column.py
@@ -212,7 +212,15 @@ class Column:
return self.expression.sql(**{"dialect": SparkSession().dialect, **kwargs})
def alias(self, name: str) -> Column:
- new_expression = exp.alias_(self.column_expression, name)
+ from sqlglot.dataframe.sql.session import SparkSession
+
+ dialect = SparkSession().dialect
+ alias: exp.Expression = sqlglot.maybe_parse(name, dialect=dialect)
+ new_expression = exp.alias_(
+ self.column_expression,
+ alias.this if isinstance(alias, exp.Column) else name,
+ dialect=dialect,
+ )
return Column(new_expression)
def asc(self) -> Column: