Skip to content

Conversation

@kasztp
Copy link
Contributor

@kasztp kasztp commented Sep 30, 2023

Fix Python language code sample in the docs for StreamingQueryListener:
Reporting Metrics programmatically using Asynchronous APIs section.

What changes were proposed in this pull request?

The code sample in the Reporting Metrics programmatically using Asynchronous APIs section was this:

spark = ...

class Listener(StreamingQueryListener):
    def onQueryStarted(self, event):
        print("Query started: " + queryStarted.id)

    def onQueryProgress(self, event):
        println("Query terminated: " + queryTerminated.id)

    def onQueryTerminated(self, event):
        println("Query made progress: " + queryProgress.progress)


spark.streams.addListener(Listener())

Which is not a proper Python code, and has QueryProgress and QueryTerminated prints mixed. Proposed change/fix:

spark = ...

class Listener(StreamingQueryListener):
    def onQueryStarted(self, event):
        print("Query started: " + queryStarted.id)

    def onQueryProgress(self, event):
        print("Query made progress: " + queryProgress.progress)

    def onQueryTerminated(self, event):
        print("Query terminated: " + queryTerminated.id)


spark.streams.addListener(Listener())

Why are the changes needed?

To fix docimentation errors.

Does this PR introduce any user-facing change?

Yes. -> Sample python code snippet is fixed in docs (see above).

How was this patch tested?

Checked with github's .md preview, and built the docs according to the readme.

Was this patch authored or co-authored using generative AI tooling?

No.

Fix python language code sample for StreamingQueryListener:
Reporting Metrics programmatically using Asynchronous APIs
@github-actions github-actions bot added the DOCS label Sep 30, 2023
@srowen
Copy link
Member

srowen commented Oct 1, 2023

Just retrigger tests for completeness

@kasztp kasztp closed this Oct 2, 2023
@kasztp kasztp reopened this Oct 2, 2023
@kasztp
Copy link
Contributor Author

kasztp commented Oct 2, 2023

Just retrigger tests for completeness

Done.

@srowen srowen closed this in d708fd7 Oct 2, 2023
srowen pushed a commit that referenced this pull request Oct 2, 2023
…rting Metrics programmatically using Asynchronous APIs

Fix Python language code sample in the docs for _StreamingQueryListener_:
Reporting Metrics programmatically using Asynchronous APIs section.

### What changes were proposed in this pull request?
The code sample in the [Reporting Metrics programmatically using Asynchronous APIs](https://spark.apache.org/docs/latest/structured-streaming-programming-guide.html#reporting-metrics-programmatically-using-asynchronous-apis) section was this:
```
spark = ...

class Listener(StreamingQueryListener):
    def onQueryStarted(self, event):
        print("Query started: " + queryStarted.id)

    def onQueryProgress(self, event):
        println("Query terminated: " + queryTerminated.id)

    def onQueryTerminated(self, event):
        println("Query made progress: " + queryProgress.progress)

spark.streams.addListener(Listener())
```

Which is not a proper Python code, and has QueryProgress and QueryTerminated prints mixed. Proposed change/fix:
```
spark = ...

class Listener(StreamingQueryListener):
    def onQueryStarted(self, event):
        print("Query started: " + queryStarted.id)

    def onQueryProgress(self, event):
        print("Query made progress: " + queryProgress.progress)

    def onQueryTerminated(self, event):
        print("Query terminated: " + queryTerminated.id)

spark.streams.addListener(Listener())
```

### Why are the changes needed?
To fix docimentation errors.

### Does this PR introduce _any_ user-facing change?
Yes. -> Sample python code snippet is fixed in docs (see above).

### How was this patch tested?
Checked with github's .md preview, and built the docs according to the readme.

### Was this patch authored or co-authored using generative AI tooling?
No.

Closes #43190 from kasztp/master.

Authored-by: Peter Kaszt <kasztp@gmail.com>
Signed-off-by: Sean Owen <srowen@gmail.com>
(cherry picked from commit d708fd7)
Signed-off-by: Sean Owen <srowen@gmail.com>
@srowen
Copy link
Member

srowen commented Oct 2, 2023

Merged to master/3.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants