zhengruifeng commented on code in PR #44349:
URL: https://github.com/apache/spark/pull/44349#discussion_r1426501966
##########
python/pyspark/errors/exceptions/base.py:
##########
@@ -294,3 +315,70 @@ class PySparkImportError(PySparkException, ImportError):
"""
Wrapper class for ImportError to support error classes.
"""
+
+
+class QueryContextType(Enum):
+ SQL = 0
+ DataFrame = 1
+
+
+class QueryContext:
+ def __init__(self, q: Any):
+ self._q = q
+
+ def contextType(self) -> QueryContextType:
+ if hasattr(self._q, "contextType"):
+ context_type = self._q.contextType().toString()
Review Comment:
shall we add a `assert(context_type in ['SQL', 'DataFrame']`) here?
##########
python/pyspark/errors/exceptions/base.py:
##########
@@ -294,3 +315,70 @@ class PySparkImportError(PySparkException, ImportError):
"""
Wrapper class for ImportError to support error classes.
"""
+
+
+class QueryContextType(Enum):
+ SQL = 0
+ DataFrame = 1
+
+
+class QueryContext:
+ def __init__(self, q: Any):
+ self._q = q
+
+ def contextType(self) -> QueryContextType:
+ if hasattr(self._q, "contextType"):
+ context_type = self._q.contextType().toString()
+ if context_type == "SQL":
+ context_type = 0
+ else:
+ context_type = 1
+ else:
+ context_type = self._q.context_type
Review Comment:
`q` here can be either a py4j object or a protobuf? ok
##########
python/pyspark/errors/exceptions/base.py:
##########
@@ -294,3 +315,70 @@ class PySparkImportError(PySparkException, ImportError):
"""
Wrapper class for ImportError to support error classes.
"""
+
+
+class QueryContextType(Enum):
+ SQL = 0
+ DataFrame = 1
+
+
+class QueryContext:
+ def __init__(self, q: Any):
+ self._q = q
+
+ def contextType(self) -> QueryContextType:
+ if hasattr(self._q, "contextType"):
+ context_type = self._q.contextType().toString()
+ if context_type == "SQL":
+ context_type = 0
+ else:
+ context_type = 1
+ else:
+ context_type = self._q.context_type
Review Comment:
where is this `context_type` coming from?
--
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]