Skip to content

Implement Cluster 2 spark.write fidelity - #23

Merged
engineeringmadness merged 8 commits into
masterfrom
cursor/spark-write-cluster-2-56a6
Sep 4, 2026
Merged

Implement Cluster 2 spark.write fidelity#23
engineeringmadness merged 8 commits into
masterfrom
cursor/spark-write-cluster-2-56a6

Conversation

@engineeringmadness

@engineeringmadness engineeringmadness commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Implements Cluster 2 from docs/superpowers/specs/2026-09-03-spark-write-lakeflow-roadmap-design.md: Spark DataFrameWriter / catalog save-mode fidelity backed by CSV + temp views.

Done (W1–W8)

  • W1. error / errorIfExists / ignore save modes
  • W2. insertInto (table must exist; overwrite=True or mode("overwrite") replaces)
  • W3. partitionBy column validation + replaceWhere overwrite-where
  • W4. CSV options (delimiter, quote, escape, nullValue, date/timestamp formats) persisted for read.table round-trips
  • W5. parquet / json / save / format().save(); delta file saves are parquet-on-disk
  • W6. overwriteSchema / mergeSchema truth table (documented in README)
  • W7. bucketBy / sortBy accepted no-ops
  • W8. Minimal writeTo(...).create()/replace()/append() façade; createOrReplace / overwritePartitions raise NotImplementedError

Testing

python3.14 -m coverage run -m pytest tests/ -v172 passed. Coverage report ~98%.

Open in Web Open in Cursor 

cursoragent and others added 8 commits September 4, 2026 03:00
saveAsTable now raises AnalysisException when the CSV already exists
for error/errorIfExists, and skip the write without touching the file
or temp view for ignore. Unknown modes raise ValueError.

Co-authored-by: gkaran184 <gkaran184@gmail.com>
insertInto requires the table CSV to exist and raises a Spark-like
AnalysisException otherwise. Default behavior appends; overwrite=True
or mode('overwrite') replaces rows.

Co-authored-by: gkaran184 <gkaran184@gmail.com>
Unknown partition columns raise at write time. replaceWhere with
overwrite deletes matching CSV rows via a pandas query, then appends
the new frame atomically.

Co-authored-by: gkaran184 <gkaran184@gmail.com>
saveAsTable stores delimiter, quote, escape, nullValue, and date/timestamp
formats next to the CSV so read.table round-trips without repeating options.
File csv() writes continue to pass options through to native Spark.

Co-authored-by: gkaran184 <gkaran184@gmail.com>
File APIs write under base_path via native Spark. format('delta').save()
stores parquet on disk; unknown file formats raise instead of failing
with AttributeError.

Co-authored-by: gkaran184 <gkaran184@gmail.com>
Overwrite with a changed schema requires overwriteSchema=true.
Append can union extra columns when mergeSchema=true; overlapping
type conflicts still raise SchemaMismatchError. README documents
the save-mode and schema matrix.

Co-authored-by: gkaran184 <gkaran184@gmail.com>
Production writer chains that bucket and sort no longer raise
AttributeError; bucketing is logged and not simulated.

Co-authored-by: gkaran184 <gkaran184@gmail.com>
create/replace/append map to the CSV catalog writer. createOrReplace
and overwritePartitions raise NotImplementedError with a saveAsTable
migration hint.

Co-authored-by: gkaran184 <gkaran184@gmail.com>
@engineeringmadness
engineeringmadness marked this pull request as ready for review September 4, 2026 03:13
@engineeringmadness
engineeringmadness merged commit c8b6aaa into master Sep 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants