Repository navigation
fix: classify SQL DML/CTAS queries as eager in _sql_lazy_transformation - #244
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request enhances the SQL query classification logic in ManagedSparkSession to accurately distinguish between lazy queries (such as SELECT, VALUES, TABLE, FROM, or WITH ...) and eager DML/DDL operations. It introduces a robust SQL lexical parser to skip comments, whitespace, and parenthesized blocks, ensuring correct classification. Additionally, exception outcome classification is updated to be case-insensitive and support SPARK_JOB_CANCELLED. The review feedback suggests improving the SQL parser to support double-quoted CTE identifiers in _is_lazy_sql_query and adding corresponding test cases.
ptch314
force-pushed
the
fix/sql-dml-and-cancel-matching
branch
from
November 30, 2026 22:09
cb2187b to
80cbede
Compare
ptch314
force-pushed
the
fix/sql-dml-and-cancel-matching
branch
from
November 30, 2026 22:21
80cbede to
1dda5bc
Compare
tim-u
approved these changes
Nov 30, 2026
tim-u
requested changes
Nov 30, 2026
tim-u
left a comment
Contributor
There was a problem hiding this comment.
Removing accidental approval
ptch314
force-pushed
the
fix/sql-dml-and-cancel-matching
branch
from
December 1, 2026 18:08
5e93c9a to
b35e1b7
Compare
tim-u
approved these changes
Dec 1, 2026
ptch314
force-pushed
the
fix/sql-dml-and-cancel-matching
branch
from
December 1, 2026 23:50
b35e1b7 to
a9302fd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #237 (
feat/spark-connect-cell-monitoring). Do not merge until #237 lands.Fixes a pre-existing
mainbug inManagedSparkSession._sql_lazy_transformation(req):Summary
ManagedSparkSession._sql_lazy_transformation(req)previously checked"select" in query.strip().lower().split(), which falsely classifiedINSERT INTO ... SELECT ...,CREATE TABLE ... AS SELECT ...,MERGE ... USING (SELECT ...),FROM ... INSERT INTO/OVERWRITE,UPDATE,DELETE,CACHE,COPY, etc. as lazy and suppressed Spark UI operation links when cell monitoring is inactive or unsupported (or skipped cell monitoring on feat: integrate ManagedSparkSession with Spark Connect cell monitoring #237)._is_lazy_sql_query+ SQL comment/raw-string/quote/paren/FROM-statement helpers), treating leadingSELECT,VALUES,TABLE, non-INSERTFROMqueries, andWITH ...CTEs (including optionalASand nested parenthesizedWITH) whose main statement is a query as lazy while classifyingINSERT,CREATE,REPLACE,MERGE,UPDATE,DELETE,CACHE,COPY,FROM ... INSERT INTO/OVERWRITE, etc. as eager. Supports backtick- and double-quoted CTE identifiers.tests/unit/test_session.py(test_sql_lazy_transformation) andtests/unit/test_cell_monitoring.pyverifying cell monitoring runs and legacy operation links emit for DML/CTAS when unmonitored while skipping pureSELECTqueries.Verification
.venv/bin/pyink . --check—55 files would be left unchanged.venv/bin/vermin --no-tips --violations --eval-annotations --target=3.10- google tests setup.py—Minimum required versions: 3.10.venv/bin/python -m pytest tests/unit/ -v --tb=short -n 2—792 passed, 17 skipped, 141 subtests passed(17Windows IDE capture fixture tests skipped on Linux)