itholic commented on code in PR #40722:
URL: https://github.com/apache/spark/pull/40722#discussion_r1168280018
##########
python/pyspark/pandas/internal.py:
##########
@@ -987,34 +986,52 @@ def attach_distributed_sequence_column(
[], schema=StructType().add(column_name,
data_type=LongType(), nullable=False)
)
- def spark_column_for(self, label: Label) -> Column:
+ def spark_column_for(self, label: Label) -> PySparkColumn:
"""Return Spark Column for the given column label."""
column_labels_to_scol = dict(zip(self.column_labels,
self.data_spark_columns))
if label in column_labels_to_scol:
return column_labels_to_scol[label]
else:
raise KeyError(name_like_string(label))
- def spark_column_name_for(self, label_or_scol: Union[Label, Column]) ->
str:
+ def spark_column_name_for(self, label_or_scol: Union[Label,
PySparkColumn]) -> str:
"""Return the actual Spark column name for the given column label."""
- if isinstance(label_or_scol, (Column, ConnectColumn)):
+ if is_remote():
+ from pyspark.sql.connect.column import Column as ConnectColumn
+
+ Column = ConnectColumn
+ else:
+ Column = PySparkColumn # type: ignore[assignment]
+ if isinstance(label_or_scol, Column):
Review Comment:
Nice!
--
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]