Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Avoid exception caused by broadcasting empty result #92

Merged
merged 2 commits into from
Feb 23, 2024

Conversation

wForget
Copy link
Member

@wForget wForget commented Feb 22, 2024

Which issue does this PR close?

Closes #91.

Rationale for this change

What changes are included in this PR?

How are these changes tested?

val expected = (0 until numParts).flatMap(_ => (0 until 5).map(i => i + 1)).sorted

assert(rowContents === expected)
Seq(true, false).foreach { emptyBroadcast =>
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, the test looks complicated by the change. Could you add a new test for empty broadcast case instead of modifying current one?

Copy link
Member Author

Choose a reason for hiding this comment

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

sure, added

@@ -81,7 +81,11 @@ abstract class CometExec extends CometPlan {

out.flush()
out.close()
Iterator((count, cbbos.toChunkedByteBuffer))
if (out.size() > 0) {
Copy link
Member

Choose a reason for hiding this comment

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

I think this is due to the extra bytes being written in the encode compressed stream, causing it to be determined not empty in CometExec$.decodeBatches.

If there are extra bytes written, is out.size() 0?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I see. The compressed stream is wrapped in out. When it is flushed, it might write compression related bytes which are not counted in out.size().

Copy link
Contributor

Choose a reason for hiding this comment

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

How about we check count > 0 instead?

Copy link
Member

Choose a reason for hiding this comment

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

I think that is same.

Copy link
Member

@sunchao sunchao left a comment

Choose a reason for hiding this comment

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

LGTM too

@sunchao sunchao merged commit 995404c into apache:main Feb 23, 2024
14 checks passed
@sunchao
Copy link
Member

sunchao commented Feb 23, 2024

Merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception occurred while broadcasting an empty result
4 participants