Skip to content

Upsert operation migration and verification#48

Draft
Copilot wants to merge 68 commits into
upsertfrom
copilot/sub-pr-47
Draft

Upsert operation migration and verification#48
Copilot wants to merge 68 commits into
upsertfrom
copilot/sub-pr-47

Conversation

Copilot AI commented Jan 2, 2026

Copy link
Copy Markdown

Description

Verified the upsert operation migration to this branch is complete. The operation provides high-performance upsert functionality using optimized DataFrame joins and partition filtering.

Implementation highlights:

  • DeltaOps::upsert(source, join_keys) API for conflict-based updates
  • Partition-aware scanning to minimize data read
  • Manual join logic for conflict detection without full materialization
  • Comprehensive metrics tracking (files, conflicts, execution time)

Test coverage:

  • 9 test cases covering no-conflicts, single/multi-file conflicts, duplicate handling, partitioning, and schema reordering
  • All 355 library tests passing

Related Issue(s)

N/A - Migration verification

Documentation

See crates/core/src/operations/upsert.rs for implementation details and inline documentation.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

alexwilcoxson-rel and others added 30 commits May 19, 2025 20:59
fix: handle edge in schema adapter for single missing field
fix: use provided sessionState in method argument
fix: scan time was always 0 for merge metrics
Co-authored-by: adampolomski <10196659+adampolomski@users.noreply.github.com>
Co-authored-by: adampolomski <10196659+adampolomski@users.noreply.github.com>
…dability-metrics

Refactor upsert.rs for improved readability, idiomatic Rust, and meaningful metrics
adampolomski and others added 22 commits December 12, 2025 00:27
… detection

Instead of caching the conflicts DataFrame to work around DataFusion's Dictionary
encoding schema mismatch, implement manual join logic:
- Collect target DataFrame with join keys + file paths (small result)
- Collect distinct source join keys (small result)
- Perform join in memory using HashSet for efficient lookup
- Extract file paths that have matching keys

This avoids materializing large DataFrames while still handling the schema
inconsistency by working entirely in memory on small, already-collected data.

Memory impact: Only materializes join keys + file paths (one row per conflicting
file), not full row data. Much more efficient than caching full DataFrames.

Co-authored-by: adampolomski <10196659+adampolomski@users.noreply.github.com>
The previous approach incorrectly materialized the entire target DataFrame which
could be billions of rows. The corrected approach:

1. Keeps target_df and source lazy (not materialized)
2. Performs inner join in DataFusion (lazy operation)
3. Selects only minimal columns (join keys + file path, not full rows)
4. Collects ONLY the join result which is small (only conflicting rows)

Memory footprint: For a table with billions of rows but only thousands of
conflicts, we materialize only thousands of rows with minimal columns, not
billions of full rows.

The join result is inherently small because it contains only rows where join
keys match between source and target (actual conflicts).

Co-authored-by: adampolomski <10196659+adampolomski@users.noreply.github.com>
…rics

- Changed extract_conflicting_filenames to extract_conflicts_dataframe to return a DataFrame
- Added extract_file_paths_from_conflicts to extract file paths from the cached DataFrame
- Cache the conflicts DataFrame for reuse in multiple places
- Added num_conflicting_records field to UpsertMetrics
- Count and report conflicting records in metrics
- Updated tests to verify num_conflicting_records metric

Co-authored-by: adampolomski <10196659+adampolomski@users.noreply.github.com>
Co-authored-by: adampolomski <10196659+adampolomski@users.noreply.github.com>
Co-authored-by: adampolomski <10196659+adampolomski@users.noreply.github.com>
…sert' into copilot/extract-dataframe-for-upsert

# Conflicts:
#	crates/core/src/operations/upsert.rs
…or-upsert

Extract conflicts DataFrame and add conflicting records metric to upsert
…or-upsert

Copilot/extract dataframe for upsert
Upsert performance and monitoring improvements
Copilot AI mentioned this pull request Jan 2, 2026
Copilot AI changed the title [WIP] Update migration for upsert operation Upsert operation migration and verification Jan 2, 2026
Copilot AI requested a review from adampolomski January 2, 2026 10:43
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.

4 participants