Skip to content

[SPARK-51056][PYTHON] Avoid unnecessary object creation in SparkSession.getActiveSession.#49758

Closed
ueshin wants to merge 2 commits intoapache:masterfrom
ueshin:issues/SPARK-51056/getactivesession
Closed

[SPARK-51056][PYTHON] Avoid unnecessary object creation in SparkSession.getActiveSession.#49758
ueshin wants to merge 2 commits intoapache:masterfrom
ueshin:issues/SPARK-51056/getactivesession

Conversation

@ueshin
Copy link
Member

@ueshin ueshin commented Feb 1, 2025

What changes were proposed in this pull request?

Avoids unnecessary object creation in SparkSession.getActiveSession.

Why are the changes needed?

SparkSession.getActiveSession tries to create a new SparkSession instance, but the instance will not be used in many cases.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

The existing tests should pass.

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

No.

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.

+1, this optimization looks reasonable to me, too. Thank you, @ueshin .

(Pending CIs).

Copy link
Contributor

@itholic itholic left a comment

Choose a reason for hiding this comment

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

Nice improvement. Thanks @ueshin

@ueshin
Copy link
Member Author

ueshin commented Feb 1, 2025

The remaining tests are not related to this PR.

@ueshin
Copy link
Member Author

ueshin commented Feb 1, 2025

Thanks! merging to master/4.0.

@ueshin ueshin closed this in e1c8b4d Feb 1, 2025
ueshin added a commit that referenced this pull request Feb 1, 2025
…on.getActiveSession

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

Avoids unnecessary object creation in `SparkSession.getActiveSession`.

### Why are the changes needed?

`SparkSession.getActiveSession` tries to create a new `SparkSession` instance, but the instance will not be used in many cases.

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

No.

### How was this patch tested?

The existing tests should pass.

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

No.

Closes #49758 from ueshin/issues/SPARK-51056/getactivesession.

Lead-authored-by: Takuya Ueshin <ueshin@databricks.com>
Co-authored-by: Takuya UESHIN <ueshin@databricks.com>
Signed-off-by: Takuya Ueshin <ueshin@databricks.com>
(cherry picked from commit e1c8b4d)
Signed-off-by: Takuya Ueshin <ueshin@databricks.com>
zifeif2 pushed a commit to zifeif2/spark that referenced this pull request Nov 14, 2025
…on.getActiveSession

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

Avoids unnecessary object creation in `SparkSession.getActiveSession`.

### Why are the changes needed?

`SparkSession.getActiveSession` tries to create a new `SparkSession` instance, but the instance will not be used in many cases.

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

No.

### How was this patch tested?

The existing tests should pass.

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

No.

Closes apache#49758 from ueshin/issues/SPARK-51056/getactivesession.

Lead-authored-by: Takuya Ueshin <ueshin@databricks.com>
Co-authored-by: Takuya UESHIN <ueshin@databricks.com>
Signed-off-by: Takuya Ueshin <ueshin@databricks.com>
(cherry picked from commit 2c8562c)
Signed-off-by: Takuya Ueshin <ueshin@databricks.com>
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.

3 participants