You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "ueshin (via GitHub)" <gi...@apache.org> on 2025/02/26 00:16:44 UTC
[PR] [SPARK-51313][PYTHON] Fix timestamp format for PySparkLogger [spark]
ueshin opened a new pull request, #50081:
URL: https://github.com/apache/spark/pull/50081
### What changes were proposed in this pull request?
Fixes timestamp format for `PySparkLogger`.
### Why are the changes needed?
Currently the timestamp format in JSON string from `PySparkLogger` can't be read by Spark with the given schema, which results in the timestamp as `NULL`.
### Does this PR introduce _any_ user-facing change?
Yes, the JSON string written by `PySparkLogger` can be read by Spark with the given schema.
For example:
```py
>>> import logging
>>> from pyspark.logger import PySparkLogger, SPARK_LOG_SCHEMA
>>>
>>> logger = PySparkLogger.getLogger("TestLogger")
>>> logfile = 'test_log'
>>> handler = logging.FileHandler(logfile)
>>> logger.addHandler(handler)
>>> logger.setLevel(logging.INFO)
>>>
>>> logger.info("Test logging structure.")
```
- before
```py
>>> spark.read.format("json").schema(SPARK_LOG_SCHEMA).load(logfile).show(truncate=False)
+----+-----+-----------------------+-------+---------+----------+
|ts |level|msg |context|exception|logger |
+----+-----+-----------------------+-------+---------+----------+
|NULL|INFO |Test logging structure.|{} |NULL |TestLogger|
+----+-----+-----------------------+-------+---------+----------+
```
- after
```py
>>> spark.read.format("json").schema(SPARK_LOG_SCHEMA).load(logfile).show(truncate=False)
+-----------------------+-----+-----------------------+-------+---------+----------+
|ts |level|msg |context|exception|logger |
+-----------------------+-----+-----------------------+-------+---------+----------+
|2025-02-25 16:13:18.306|INFO |Test logging structure.|{} |NULL |TestLogger|
+-----------------------+-----+-----------------------+-------+---------+----------+
```
### How was this patch tested?
Added the related tests.
### Was this patch authored or co-authored using generative AI tooling?
No.
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-51313][PYTHON] Fix timestamp format for PySparkLogger [spark]
Posted by "ueshin (via GitHub)" <gi...@apache.org>.
ueshin closed pull request #50081: [SPARK-51313][PYTHON] Fix timestamp format for PySparkLogger
URL: https://github.com/apache/spark/pull/50081
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-51313][PYTHON] Fix timestamp format for PySparkLogger [spark]
Posted by "ueshin (via GitHub)" <gi...@apache.org>.
ueshin commented on PR #50081:
URL: https://github.com/apache/spark/pull/50081#issuecomment-2683908571
Thanks! merging to master/4.0.
--
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-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org