Skip to content

Commit

Permalink
[SPARK-48752][FOLLOWUP][PYTHON][DOCS] Use explicit name for line numb…
Browse files Browse the repository at this point in the history
…er in log

### What changes were proposed in this pull request?

This PR followups for apache#47145 to rename the log field naming

### Why are the changes needed?

`line_no` is not very intuitive so we better renaming to `line_number` explicitly.

### Does this PR introduce _any_ user-facing change?

No API change, but user-facing log message will be improved

### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
-->
The existing CI should pass

### Was this patch authored or co-authored using generative AI tooling?
<!--
If generative AI tooling has been used in the process of authoring this patch, please include the
phrase: 'Generated-by: ' followed by the name of the tool and its version.
If no, write 'No'.
Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
-->
No

Closes apache#47437 from itholic/logger_followup.

Authored-by: Haejoon Lee <haejoon.lee@databricks.com>
Signed-off-by: Haejoon Lee <haejoon.lee@databricks.com>
  • Loading branch information
itholic authored and ilicmarkodb committed Jul 29, 2024
1 parent 610046a commit 299fddd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion python/docs/source/development/logger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Example log entry:
"msg": "[DIVIDE_BY_ZERO] Division by zero. Use `try_divide` to tolerate divisor being 0 and return NULL instead. If necessary set \"spark.sql.ansi.enabled\" to \"false\" to bypass this error. SQLSTATE: 22012\n== DataFrame ==\n\"divide\" was called from\n/.../spark/python/test_error_context.py:17\n",
"context": {
"file": "/path/to/file.py",
"line_no": "17",
"line": "17",
"fragment": "divide"
"error_class": "DIVIDE_BY_ZERO"
},
Expand Down
4 changes: 2 additions & 2 deletions python/pyspark/errors/exceptions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ def _log_exception(self) -> None:
if query_context.contextType().name == "DataFrame":
logger = PySparkLogger.getLogger("DataFrameQueryContextLogger")
call_site = query_context.callSite().split(":")
line_no = call_site[1] if len(call_site) == 2 else ""
line = call_site[1] if len(call_site) == 2 else ""
logger.exception(
self.getMessage(),
file=call_site[0],
line_no=line_no,
line=line,
fragment=query_context.fragment(),
error_class=self.getErrorClass(),
)
Expand Down

0 comments on commit 299fddd

Please sign in to comment.