Skip to content

Conversation

@rednaxelafx
Copy link
Contributor

@rednaxelafx rednaxelafx commented Jun 5, 2023

What changes were proposed in this pull request?

Handle the exception message from Structured Streaming's QueryTerminatedEvent in StreamingQueryStatusListener, so that the Structured Streaming UI can display the status and error message correctly for failed queries.

Why are the changes needed?

The original implementation of the Structured Streaming UI had a copy-and-paste bug where it forgot to handle the exception from QueryTerminatedEvent in StreamingQueryStatusListener.onQueryTerminated, so that field is never updated in the UI data, i.e. it's always None. In turn, the UI would always show the status of failed queries as FINISHED instead of FAILED.

Does this PR introduce any user-facing change?

Yes. Failed Structured Streaming queries would show incorrectly as FINISHED before the fix:
Screenshot 2023-06-05 at 3 58 16 PM
and show correctly as FAILED after the fix:
Screenshot 2023-06-05 at 3 56 07 PM

The example query is:

implicit val ctx = spark.sqlContext
import org.apache.spark.sql.execution.streaming.MemoryStream
spark.conf.set("spark.sql.ansi.enabled", "true")
val inputData = MemoryStream[(Int, Int)]
val df = inputData.toDF().selectExpr("_1 / _2 as a")
inputData.addData((1, 2), (3, 4), (5, 6), (7, 0))
val testQuery = df.writeStream.format("memory").queryName("kristest").outputMode("append").start
testQuery.processAllAvailable()

How was this patch tested?

Added UT to StreamingQueryStatusListenerSuite

@gengliangwang
Copy link
Member

Merging to master/3.4

gengliangwang pushed a commit that referenced this pull request Jun 6, 2023
…ueries correctly

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

Handle the `exception` message from Structured Streaming's `QueryTerminatedEvent` in `StreamingQueryStatusListener`, so that the Structured Streaming UI can display the status and error message correctly for failed queries.

### Why are the changes needed?

The original implementation of the Structured Streaming UI had a copy-and-paste bug where it forgot to handle the `exception` from `QueryTerminatedEvent` in `StreamingQueryStatusListener.onQueryTerminated`, so that field is never updated in the UI data, i.e. it's always `None`. In turn, the UI would always show the status of failed queries as `FINISHED` instead of `FAILED`.

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

Yes. Failed Structured Streaming queries would show incorrectly as `FINISHED` before the fix:
![Screenshot 2023-06-05 at 3 58 16 PM](https://github.com/apache/spark/assets/107834/32d91148-7a27-4723-9748-ec8a7596ee61)
and show correctly as `FAILED` after the fix:
![Screenshot 2023-06-05 at 3 56 07 PM](https://github.com/apache/spark/assets/107834/16b1df32-1804-4f49-aede-d775f8db7666)

The example query is:
```scala
implicit val ctx = spark.sqlContext
import org.apache.spark.sql.execution.streaming.MemoryStream
spark.conf.set("spark.sql.ansi.enabled", "true")
val inputData = MemoryStream[(Int, Int)]
val df = inputData.toDF().selectExpr("_1 / _2 as a")
inputData.addData((1, 2), (3, 4), (5, 6), (7, 0))
val testQuery = df.writeStream.format("memory").queryName("kristest").outputMode("append").start
testQuery.processAllAvailable()
```

### How was this patch tested?

Added UT to `StreamingQueryStatusListenerSuite`

Closes #41468 from rednaxelafx/fix-streaming-ui.

Authored-by: Kris Mok <[email protected]>
Signed-off-by: Gengliang Wang <[email protected]>
(cherry picked from commit 51a919e)
Signed-off-by: Gengliang Wang <[email protected]>
@kazuyukitanimura
Copy link
Contributor

@rednaxelafx @gengliangwang Looks like CI is failing for 3.4, FYI

@dongjoon-hyun
Copy link
Member

Thank you for reporting, @kazuyukitanimura . I'm looking at it now

@dongjoon-hyun
Copy link
Member

The difference is the following. I'll make a follow-up PR quickly.

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a follow-up. Let's wait for the CI result.

dongjoon-hyun added a commit that referenced this pull request Jun 6, 2023
…ing QueryTerminatedEvent constructor

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

This is a follow-up of #41468 to fix `branch-3.4`'s compilation issue.

### Why are the changes needed?

To recover the compilation.

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

No.

### How was this patch tested?
Pass the CIs.

Closes #41484 from dongjoon-hyun/SPARK-43973.

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
czxm pushed a commit to czxm/spark that referenced this pull request Jun 12, 2023
…ueries correctly

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

Handle the `exception` message from Structured Streaming's `QueryTerminatedEvent` in `StreamingQueryStatusListener`, so that the Structured Streaming UI can display the status and error message correctly for failed queries.

### Why are the changes needed?

The original implementation of the Structured Streaming UI had a copy-and-paste bug where it forgot to handle the `exception` from `QueryTerminatedEvent` in `StreamingQueryStatusListener.onQueryTerminated`, so that field is never updated in the UI data, i.e. it's always `None`. In turn, the UI would always show the status of failed queries as `FINISHED` instead of `FAILED`.

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

Yes. Failed Structured Streaming queries would show incorrectly as `FINISHED` before the fix:
![Screenshot 2023-06-05 at 3 58 16 PM](https://github.com/apache/spark/assets/107834/32d91148-7a27-4723-9748-ec8a7596ee61)
and show correctly as `FAILED` after the fix:
![Screenshot 2023-06-05 at 3 56 07 PM](https://github.com/apache/spark/assets/107834/16b1df32-1804-4f49-aede-d775f8db7666)

The example query is:
```scala
implicit val ctx = spark.sqlContext
import org.apache.spark.sql.execution.streaming.MemoryStream
spark.conf.set("spark.sql.ansi.enabled", "true")
val inputData = MemoryStream[(Int, Int)]
val df = inputData.toDF().selectExpr("_1 / _2 as a")
inputData.addData((1, 2), (3, 4), (5, 6), (7, 0))
val testQuery = df.writeStream.format("memory").queryName("kristest").outputMode("append").start
testQuery.processAllAvailable()
```

### How was this patch tested?

Added UT to `StreamingQueryStatusListenerSuite`

Closes apache#41468 from rednaxelafx/fix-streaming-ui.

Authored-by: Kris Mok <[email protected]>
Signed-off-by: Gengliang Wang <[email protected]>
snmvaughan pushed a commit to snmvaughan/spark that referenced this pull request Jun 20, 2023
…ueries correctly

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

Handle the `exception` message from Structured Streaming's `QueryTerminatedEvent` in `StreamingQueryStatusListener`, so that the Structured Streaming UI can display the status and error message correctly for failed queries.

### Why are the changes needed?

The original implementation of the Structured Streaming UI had a copy-and-paste bug where it forgot to handle the `exception` from `QueryTerminatedEvent` in `StreamingQueryStatusListener.onQueryTerminated`, so that field is never updated in the UI data, i.e. it's always `None`. In turn, the UI would always show the status of failed queries as `FINISHED` instead of `FAILED`.

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

Yes. Failed Structured Streaming queries would show incorrectly as `FINISHED` before the fix:
![Screenshot 2023-06-05 at 3 58 16 PM](https://github.com/apache/spark/assets/107834/32d91148-7a27-4723-9748-ec8a7596ee61)
and show correctly as `FAILED` after the fix:
![Screenshot 2023-06-05 at 3 56 07 PM](https://github.com/apache/spark/assets/107834/16b1df32-1804-4f49-aede-d775f8db7666)

The example query is:
```scala
implicit val ctx = spark.sqlContext
import org.apache.spark.sql.execution.streaming.MemoryStream
spark.conf.set("spark.sql.ansi.enabled", "true")
val inputData = MemoryStream[(Int, Int)]
val df = inputData.toDF().selectExpr("_1 / _2 as a")
inputData.addData((1, 2), (3, 4), (5, 6), (7, 0))
val testQuery = df.writeStream.format("memory").queryName("kristest").outputMode("append").start
testQuery.processAllAvailable()
```

### How was this patch tested?

Added UT to `StreamingQueryStatusListenerSuite`

Closes apache#41468 from rednaxelafx/fix-streaming-ui.

Authored-by: Kris Mok <[email protected]>
Signed-off-by: Gengliang Wang <[email protected]>
(cherry picked from commit 51a919e)
Signed-off-by: Gengliang Wang <[email protected]>
snmvaughan pushed a commit to snmvaughan/spark that referenced this pull request Jun 20, 2023
…ing QueryTerminatedEvent constructor

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

This is a follow-up of apache#41468 to fix `branch-3.4`'s compilation issue.

### Why are the changes needed?

To recover the compilation.

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

No.

### How was this patch tested?
Pass the CIs.

Closes apache#41484 from dongjoon-hyun/SPARK-43973.

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
GladwinLee pushed a commit to lyft/spark that referenced this pull request Oct 10, 2023
…ueries correctly

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

Handle the `exception` message from Structured Streaming's `QueryTerminatedEvent` in `StreamingQueryStatusListener`, so that the Structured Streaming UI can display the status and error message correctly for failed queries.

### Why are the changes needed?

The original implementation of the Structured Streaming UI had a copy-and-paste bug where it forgot to handle the `exception` from `QueryTerminatedEvent` in `StreamingQueryStatusListener.onQueryTerminated`, so that field is never updated in the UI data, i.e. it's always `None`. In turn, the UI would always show the status of failed queries as `FINISHED` instead of `FAILED`.

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

Yes. Failed Structured Streaming queries would show incorrectly as `FINISHED` before the fix:
![Screenshot 2023-06-05 at 3 58 16 PM](https://github.com/apache/spark/assets/107834/32d91148-7a27-4723-9748-ec8a7596ee61)
and show correctly as `FAILED` after the fix:
![Screenshot 2023-06-05 at 3 56 07 PM](https://github.com/apache/spark/assets/107834/16b1df32-1804-4f49-aede-d775f8db7666)

The example query is:
```scala
implicit val ctx = spark.sqlContext
import org.apache.spark.sql.execution.streaming.MemoryStream
spark.conf.set("spark.sql.ansi.enabled", "true")
val inputData = MemoryStream[(Int, Int)]
val df = inputData.toDF().selectExpr("_1 / _2 as a")
inputData.addData((1, 2), (3, 4), (5, 6), (7, 0))
val testQuery = df.writeStream.format("memory").queryName("kristest").outputMode("append").start
testQuery.processAllAvailable()
```

### How was this patch tested?

Added UT to `StreamingQueryStatusListenerSuite`

Closes apache#41468 from rednaxelafx/fix-streaming-ui.

Authored-by: Kris Mok <[email protected]>
Signed-off-by: Gengliang Wang <[email protected]>
(cherry picked from commit 51a919e)
Signed-off-by: Gengliang Wang <[email protected]>
GladwinLee pushed a commit to lyft/spark that referenced this pull request Oct 10, 2023
…ing QueryTerminatedEvent constructor

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

This is a follow-up of apache#41468 to fix `branch-3.4`'s compilation issue.

### Why are the changes needed?

To recover the compilation.

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

No.

### How was this patch tested?
Pass the CIs.

Closes apache#41484 from dongjoon-hyun/SPARK-43973.

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
catalinii pushed a commit to lyft/spark that referenced this pull request Oct 10, 2023
…ueries correctly

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

Handle the `exception` message from Structured Streaming's `QueryTerminatedEvent` in `StreamingQueryStatusListener`, so that the Structured Streaming UI can display the status and error message correctly for failed queries.

### Why are the changes needed?

The original implementation of the Structured Streaming UI had a copy-and-paste bug where it forgot to handle the `exception` from `QueryTerminatedEvent` in `StreamingQueryStatusListener.onQueryTerminated`, so that field is never updated in the UI data, i.e. it's always `None`. In turn, the UI would always show the status of failed queries as `FINISHED` instead of `FAILED`.

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

Yes. Failed Structured Streaming queries would show incorrectly as `FINISHED` before the fix:
![Screenshot 2023-06-05 at 3 58 16 PM](https://github.com/apache/spark/assets/107834/32d91148-7a27-4723-9748-ec8a7596ee61)
and show correctly as `FAILED` after the fix:
![Screenshot 2023-06-05 at 3 56 07 PM](https://github.com/apache/spark/assets/107834/16b1df32-1804-4f49-aede-d775f8db7666)

The example query is:
```scala
implicit val ctx = spark.sqlContext
import org.apache.spark.sql.execution.streaming.MemoryStream
spark.conf.set("spark.sql.ansi.enabled", "true")
val inputData = MemoryStream[(Int, Int)]
val df = inputData.toDF().selectExpr("_1 / _2 as a")
inputData.addData((1, 2), (3, 4), (5, 6), (7, 0))
val testQuery = df.writeStream.format("memory").queryName("kristest").outputMode("append").start
testQuery.processAllAvailable()
```

### How was this patch tested?

Added UT to `StreamingQueryStatusListenerSuite`

Closes apache#41468 from rednaxelafx/fix-streaming-ui.

Authored-by: Kris Mok <[email protected]>
Signed-off-by: Gengliang Wang <[email protected]>
(cherry picked from commit 51a919e)
Signed-off-by: Gengliang Wang <[email protected]>
catalinii pushed a commit to lyft/spark that referenced this pull request Oct 10, 2023
…ing QueryTerminatedEvent constructor

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

This is a follow-up of apache#41468 to fix `branch-3.4`'s compilation issue.

### Why are the changes needed?

To recover the compilation.

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

No.

### How was this patch tested?
Pass the CIs.

Closes apache#41484 from dongjoon-hyun/SPARK-43973.

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants