grundprinzip commented on code in PR #38984: URL: https://github.com/apache/spark/pull/38984#discussion_r1051535005
########## python/pyspark/sql/connect/plan.py: ########## @@ -343,6 +343,53 @@ def _repr_html_(self) -> str: """ +class Hint(LogicalPlan): + """Logical plan object for a Hint operation.""" + + def __init__(self, child: Optional["LogicalPlan"], name: str, params: List[Any]) -> None: + super().__init__(child) + self.name = name + self.params = params + + def _convert_value(self, v: Any) -> proto.Expression.Literal: + value = proto.Expression.Literal() + if v is None: + value.null = True + elif isinstance(v, int): + value.integer = v + elif isinstance(v, str): + value.string = v + else: + raise ValueError(f"Could not convert literal for type {type(v)}") + return value + + def plan(self, session: "SparkConnectClient") -> proto.Relation: + assert self._child is not None + plan = proto.Relation() + plan.hint.input.CopyFrom(self._child.plan(session)) + plan.hint.name = self.name + for v in self.params: + param = proto.Expression.Literal() + param.CopyFrom(self._convert_value(v)) + plan.hint.parameters.append(param) Review Comment: ```suggestion plan.hint.parameters.append(self._convert_value(v)) ``` -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org