[SPARK-58227][CONNECT] Support Spark Connect in the spark-sql CLI (spark-sql --remote)#57383
Open
dhruv-pratap wants to merge 1 commit into
Open
[SPARK-58227][CONNECT] Support Spark Connect in the spark-sql CLI (spark-sql --remote)#57383dhruv-pratap wants to merge 1 commit into
dhruv-pratap wants to merge 1 commit into
Conversation
…I (spark-sql --remote) Reference implementation for a dev@ discussion (relates to SPARK-49194). Adds a new SparkConnectSQLCLIDriver in sql/connect/client/jvm, selected on --remote / spark.api.mode=connect via SparkSubmitCommandBuilder (mirroring spark-shell / SPARK-48936 + ConnectRepl). Builds a remote SparkSession through the Connect client, executes statements via spark.sql(...), prints client-side tab-separated output, and supports -e/-f + an interactive loop. The existing SparkSQLCLIDriver (hive-thriftserver) is unchanged and remains the default; no sql/hive-thriftserver dependency. MVP scope; full hiveResultString parity, remaining flags, and init files deferred to follow-ups. Tests: server-free unit suite + an integration suite (RemoteSparkSession) that runs spark-sql --remote against a live local server. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
dhruv-pratap
force-pushed
the
spark-connect-sql-cli
branch
from
July 20, 2026 20:56
d4d57a3 to
4efb484
Compare
dhruv-pratap
marked this pull request as ready for review
July 21, 2026 01:20
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.
What changes were proposed in this pull request?
This adds Spark Connect support to the
spark-sqlCLI:spark-sql --remote sc://...starts a SQL shell backed by a remote Spark Connect session, mirroring the existing
spark-shell --remote(SPARK-48936).A new
SparkConnectSQLCLIDriveris added insql/connect/client/jvm, selected when--remote/spark.api.mode=connectis set (the same dispatchspark-shelluses). Itbuilds a remote
SparkSessionagainst thesc://URL (asConnectRepldoes), executesstatements via
spark.sql(...), prints tab-separated output client-side, and supports-e/-fand an interactive loop.The existing
SparkSQLCLIDriver(Catalyst / hive-thriftserver-coupled) is unchanged andremains the default; there is no
sql/hive-thriftserverdependency and no change toexisting public API. This completes the
--remoteentry-point set under the SPARK-49194umbrella (
spark-shell/spark-submit/pysparkalready have it);spark-sqlwas thelast interactive entry point without it.
Scope: an initial, focused implementation. Follow-ups (to be tracked as separate JIRAs):
full
hiveResultStringoutput parity (types / nulls / complex / timestamps), remainingCLI flags (
--database, init files, ...), prompt /USE dbsemantics, and aquote/comment-aware statement splitter (a robust one exists as
StringUtils.splitSemiColonin catalyst but isn't on the Connect client's classpath -- relocating it to
sql-apiforshared reuse is a candidate; guidance welcome).
Design doc: https://docs.google.com/document/d/14iOZAZFt5BN9whbbjCzZX1mVuhaKq2LEkfP6Ts4prHo/edit
dev@ discussion: https://lists.apache.org/thread/cw897hvjqlmrtdo7byr10b86wtls819l
Why are the changes needed?
spark-sqlis the last interactive entry point without Spark Connect support, and the onlyone still requiring a local Catalyst driver and the Hive Thrift Server module. This lets the
SQL CLI run against remote, service-hosted compute, consistent with the other entry points.
Does this PR introduce any user-facing change?
Yes -- a new
spark-sql --remote sc://...mode. No change to existingspark-sqlbehavior;the classic local driver remains the default.
How was this patch tested?
ConnectFunSuite):SparkConnectSQLCLIDriverSuite-- covers the-e/-fsplit from the Connect client args, statement splitting, and row formatting.SparkConnectSQLCLIDriverE2ESuite, onRemoteSparkSession): boots alocal Spark Connect server and drives the real remote path --
spark-sql --remote -e,multiple
;-separated statements, and an-fscript -- asserting rendered output.license / checkstyle all pass.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 4.8 (Claude Code)