grundprinzip commented on code in PR #39925:
URL: https://github.com/apache/spark/pull/39925#discussion_r1102971996
##########
python/pyspark/sql/connect/plan.py:
##########
@@ -40,13 +42,29 @@ class InputValidationError(Exception):
pass
-class LogicalPlan(object):
+class LogicalPlan:
+
+ _lock: Lock = Lock()
+ _nextPlanId: int = 0
INDENT = 2
def __init__(self, child: Optional["LogicalPlan"]) -> None:
self._child = child
+ plan_id: Optional[int] = None
+ with LogicalPlan._lock:
+ plan_id = LogicalPlan._nextPlanId
+ LogicalPlan._nextPlanId += 1
+
+ assert plan_id is not None
+ self._plan_id = plan_id
+
+ def _create_proto_with_plan_id(self) -> proto.Relation:
Review Comment:
My suggestion is to use a more common name when we add other default
parameters captured from the plan object.
```suggestion
def _create_proto_relation(self) -> proto.Relation:
```
##########
python/pyspark/sql/connect/dataframe.py:
##########
@@ -1280,10 +1281,12 @@ def __getitem__(self, item: Union[int, str, Column,
List, Tuple]) -> Union[Colum
if isinstance(item, str):
# Check for alias
alias = self._get_alias()
- if alias is not None:
- return col(alias)
- else:
- return col(item)
+ if self._plan is None:
+ raise Exception("Cannot analyze on empty plan.")
Review Comment:
IIRC we have now PySpark specific exception types we should use.
```suggestion
raise SparkConnectException("Cannot analyze on empty plan.")
```
--
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]