Skip to content

Conversation

@richardc-db
Copy link
Contributor

@richardc-db richardc-db commented Aug 31, 2022

What changes were proposed in this pull request?

This change ensures that, once PartitionReader.hasNext returns false once, subsequent calls to PartitionReader.hasNext will not call reader.next() (which before could cause a timeout).

Why are the changes needed?

This change prevents potential performance regressions caused by parent nodes that call PartitionIterator.hasNext even after it returns false once.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Existing tests

@github-actions github-actions bot added the SQL label Aug 31, 2022
@richardc-db richardc-db changed the title Fix repeat calls to PartitionReader.hasNext timing out [SPARK-40294][SQL] Fix repeat calls to PartitionReader.hasNext timing out Aug 31, 2022
@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@LuciferYang
Copy link
Contributor

Does DSv1 have similar problems?

reader: PartitionReader[T],
customMetrics: Map[String, SQLMetric]) extends Iterator[T] {
private[this] var valuePrepared = false
private[this] var prevHasNext = true
Copy link
Contributor

Choose a reason for hiding this comment

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

I think hasMoreInput is a better name.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

private var numRow = 0L

override def hasNext: Boolean = {
if (!valuePrepared) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you follow the change in https://github.com/apache/spark/pull/37900/files ? It can avoid entering this if branch entirely.

@cloud-fan
Copy link
Contributor

ping @richardc-db

@srowen
Copy link
Member

srowen commented Sep 19, 2022

Closed in favor of #37743

@srowen srowen closed this Sep 19, 2022
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.

6 participants