itholic commented on code in PR #39212:
URL: https://github.com/apache/spark/pull/39212#discussion_r1057037307
##########
python/pyspark/sql/connect/client.py:
##########
@@ -36,6 +41,49 @@
)
+def _configure_logging() -> logging.Logger:
+ """Configure logging for the Spark Connect clients."""
+ logger = logging.getLogger("pyspark.sql.connect.client")
+ handler = logging.StreamHandler()
+ handler.setFormatter(
+ logging.Formatter(fmt="%(asctime)s %(process)d %(levelname)s
%(funcName)s %(message)s")
+ )
+ logger.addHandler(handler)
+
+ # Check the environment variables for log levels:
+ level = os.getenv("SPARK_CONNECT_LOG_LEVEL", "none").lower()
+ if level == "info":
+ logger.setLevel(logging.INFO)
+ elif level == "warn":
+ logger.setLevel(logging.WARNING)
+ elif level == "error":
+ logger.setLevel(logging.ERROR)
+ elif level == "debug":
+ logger.setLevel(logging.DEBUG)
+ else:
+ logger.disabled = True
+ return logger
+
+
+# Instantiate the logger based on the environment configuration.
+_logger = _configure_logging()
+
+
+class SparkConnectClientException(Exception):
+ def __init__(self, message: str) -> None:
+ super(SparkConnectClientException, self).__init__(message)
+
+
+class SparkConnectAnalysisException(SparkConnectClientException):
+ def __init__(self, reason: str, message: str, plan: str) -> None:
+ self._reason = reason
+ self._message = message
+ self._plan = plan
+
+ def __str__(self) -> str:
+ return f"{self._message}\nPlan: {self._plan}"
Review Comment:
I'll integrate these new errors into centralized PySpark error framework
after https://github.com/apache/spark/pull/39137 is done.
Let me leave this comment as a just for reminder for now. (reminder ping
@itholic myself)
##########
python/pyspark/sql/connect/client.py:
##########
@@ -36,6 +41,49 @@
)
+def _configure_logging() -> logging.Logger:
+ """Configure logging for the Spark Connect clients."""
+ logger = logging.getLogger("pyspark.sql.connect.client")
+ handler = logging.StreamHandler()
+ handler.setFormatter(
+ logging.Formatter(fmt="%(asctime)s %(process)d %(levelname)s
%(funcName)s %(message)s")
+ )
+ logger.addHandler(handler)
+
+ # Check the environment variables for log levels:
+ level = os.getenv("SPARK_CONNECT_LOG_LEVEL", "none").lower()
+ if level == "info":
+ logger.setLevel(logging.INFO)
+ elif level == "warn":
+ logger.setLevel(logging.WARNING)
+ elif level == "error":
+ logger.setLevel(logging.ERROR)
+ elif level == "debug":
+ logger.setLevel(logging.DEBUG)
+ else:
+ logger.disabled = True
+ return logger
+
+
+# Instantiate the logger based on the environment configuration.
+_logger = _configure_logging()
+
+
+class SparkConnectClientException(Exception):
+ def __init__(self, message: str) -> None:
+ super(SparkConnectClientException, self).__init__(message)
+
+
+class SparkConnectAnalysisException(SparkConnectClientException):
+ def __init__(self, reason: str, message: str, plan: str) -> None:
+ self._reason = reason
+ self._message = message
+ self._plan = plan
+
+ def __str__(self) -> str:
+ return f"{self._message}\nPlan: {self._plan}"
Review Comment:
I'll integrate these new Exceptions into centralized PySpark error framework
after https://github.com/apache/spark/pull/39137 is done.
Let me leave this comment as a just for reminder for now. (reminder ping
@itholic myself)
--
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]