Skip to content

Commit 7059ecc

Browse files
authored
fix: Remove redundant empty/non-actionable per-operation Spark UI link and progress bar (#157)
1 parent 16e98e3 commit 7059ecc

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

google/cloud/dataproc_spark_connect/session.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,10 @@ def handler(
10051005
total_tasks += stage.num_tasks
10061006
completed_tasks += stage.num_completed_tasks
10071007

1008+
# Don't show progress bar till we receive some tasks
1009+
if total_tasks == 0:
1010+
return
1011+
10081012
tqdm_pbar = notebook_tqdm
10091013
if environment.is_interactive_terminal():
10101014
tqdm_pbar = cli_tqdm
@@ -1044,13 +1048,11 @@ def handler(
10441048
@staticmethod
10451049
def _sql_lazy_transformation(req):
10461050
# Select SQL command
1047-
if req.plan and req.plan.command and req.plan.command.sql_command:
1048-
return (
1049-
"select"
1050-
in req.plan.command.sql_command.sql.strip().lower().split()
1051-
)
1052-
1053-
return False
1051+
try:
1052+
query = req.plan.command.sql_command.input.sql.query
1053+
return "select" in query.strip().lower().split()
1054+
except AttributeError:
1055+
return False
10541056

10551057
def _repr_html_(self) -> str:
10561058
if not self._active_s8s_session_id:

tests/unit/test_session.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
)
3636

3737
from pyspark.sql.connect.client.core import ConfigResult
38-
from pyspark.sql.connect.proto import Command, ConfigResponse, ExecutePlanRequest, Plan, SqlCommand, UserContext
38+
from pyspark.sql.connect.proto import Command, ConfigResponse, ExecutePlanRequest, Plan, Relation, SQL, SqlCommand, UserContext
3939
from unittest import mock
4040

4141

@@ -1680,7 +1680,13 @@ def test_sql_lazy_transformation(self):
16801680
test_execute_plan_request_1: ExecutePlanRequest = ExecutePlanRequest(
16811681
session_id="mock-session_id-from-super",
16821682
client_type="mock-client_type-from-super",
1683-
plan=Plan(command=Command(sql_command=SqlCommand(sql="SELECT 1"))),
1683+
plan=Plan(
1684+
command=Command(
1685+
sql_command=SqlCommand(
1686+
input=Relation(sql=SQL(query="SELECT 1"))
1687+
)
1688+
)
1689+
),
16841690
tags=["mock-tag-from-super"],
16851691
user_context=UserContext(user_id="mock-user-from-super"),
16861692
operation_id=test_uuid,
@@ -1690,7 +1696,11 @@ def test_sql_lazy_transformation(self):
16901696
client_type="mock-client_type-from-super",
16911697
plan=Plan(
16921698
command=Command(
1693-
sql_command=SqlCommand(sql="INSERT INTO test_table_2 ...")
1699+
sql_command=SqlCommand(
1700+
input=Relation(
1701+
sql=SQL(query="INSERT INTO test_table_2 ...")
1702+
)
1703+
)
16941704
)
16951705
),
16961706
tags=["mock-tag-from-super"],
@@ -1703,7 +1713,9 @@ def test_sql_lazy_transformation(self):
17031713
plan=Plan(
17041714
command=Command(
17051715
sql_command=SqlCommand(
1706-
sql="DROP TABLE IF EXISTS selections"
1716+
input=Relation(
1717+
sql=SQL(query="DROP TABLE IF EXISTS selections")
1718+
)
17071719
)
17081720
)
17091721
),

0 commit comments

Comments
 (0)