Repository navigation
Spark Python data source (spark.read.format("arrowsql")) - #20
Open
dominikpeter wants to merge 3 commits into
Open
dominikpeter wants to merge 3 commits into
dominikpeter wants to merge 3 commits into
Conversation
spark.read.format("arrowsql") reads SQL Server in parallel on the executors
(range or hash partitioning, Arrow batches via read_arrow_stream) and
df.write.format("arrowsql") bulk-copies each task's Arrow batches.
Optional extra arrowsql[spark]; importing arrowsql does not import pyspark.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… (pyspark < 4.2) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… default differs) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This branch has not been deployed
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
arrowsql.spark: a Spark 4 Python data source.spark.read.format("arrowsql")reads SQL Server in parallel on the executors;df.write.format("arrowsql")bulk-copies each task's Arrow batches.read_arrow_streamand yieldpyarrow.RecordBatches (no rows, no pandas). Data never passes through the driver.partitionColumn+numPartitions(+ optionallowerBound/upperBound; without bounds MIN/MAX is one query on the driver) with half-open slices from arrow_parallel's_bounds_plan; the first slice also reads the NULL rows. OrhashColumns+numPartitionswith(CHECKSUM(cols) & 2147483647) % N = i. Default is one slice. Never hashes*: a query with a time-varying column (GETUTCDATE()) gave different rows per slice query.SELECT TOP 0 * FROM (<query>) AS q).timestampType:ntz(default, exactTimestampNTZType) ortimestamp(Spark JDBC'sTimestampType, wall clock read intimeZone, default UTC; Spark does not hand its session zone to data sources, so settimeZonewhen it is not UTC). Writes mirror it.write_arrow(workers=1)per task, name-based column mapping.overwrite=TRUNCATE TABLEonce on the driver, not transactional across tasks.dbtableis parsed and re-quoted, anything else is an error.arrowsql[spark];import arrowsqldoes not import pyspark. All arrowsql/pyarrow imports are insideread/writebodies.examples/spark_datasource.py(local, ran here),examples/databricks_spark_datasource.py(notebook source), CHANGELOG, ARCHITECTURE.Tests
tests/spark(37 tests, local SparkSessionlocal[3],spark.driver.memory=1g, SQL Server viascripts/run_tests.py): plain read equals cursor; range partitioning with/without bounds, NULL partition values, numPartitions > distinct values, empty table, date/datetime columns; hash partitioning; time-varying query columns (hash and range); tinyint widening; empty result; timestamp modes; large read (2M rows) on a 1g driver; SQL Server -> Delta -> read back for datetime/datetime2/decimal/uniqueidentifier/varbinary/nvarchar(max)/tinyint/bit in both timestamp modes; write append/overwrite/empty; invalid options. The module skips when pyspark or Java is missing; the Delta test skips without delta-spark.Also run: tests/port + tests/common_issues (5502 passed, 218 skipped, 1 xfailed).
No CI job added: pyspark + a JVM + delta jars are a heavy install for the runners and the Spark session start dominates the run time.
Not covered: Spark Connect clients (no session on the data source side), streaming, filter pushdown,
timecolumns (Spark 4 has no TimeType in this path).🤖 Generated with Claude Code