Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[copy_from] Support specifying a column map in COPY ... FROM <url> #31580

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ParkMyCar
Copy link
Member

@ParkMyCar ParkMyCar commented Feb 21, 2025

This PR adds support for specifying a column mapping and filling in default values for COPY ... FROM <url> (aka OneshotSource).

Let's say we ran CREATE TABLE t1 (c1 text, c2 text, c3 text DEFAULT 'apple'), so our table has 3 columns, but the file we're copying into Materialize only has 2 columns. After this PR you could run COPY INTO t1 (c2, c1) FROM <url> and it would map the first column of the data to t1.c2, the second column to t1.c1, and it would fill in the default value of 'apple' for all values in t1.c3.

We do this by planning a MapFilterProject, converting it into a SafeMfpPlan, and then in clusterd when decoding data evaluating the SafeMfpPlan for every row.

Motivation

Fixes https://github.com/MaterializeInc/database-issues/issues/8858

Tips for reviewer

There are no tests in this PR, they are included as part of #31581

Checklist

  • This PR has adequate test coverage / QA involvement has been duly considered. (trigger-ci for additional test/nightly runs)
  • This PR has an associated up-to-date design doc, is a design doc (template), or is sufficiently small to not require a design.
  • If this PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way), then it is tagged with a T-proto label.
  • If this PR will require changes to cloud orchestration or tests, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).
  • If this PR includes major user-facing behavior changes, I have pinged the relevant PM to schedule a changelog post.

* in planning create an MFP that we can pass down to clusterd
* in sequencing turn the provided MFP into a SafeMfpPlan
* in clusterd evaluate the SafeMfpPlan for every row we decode
@ParkMyCar ParkMyCar force-pushed the copy-from/projection branch from 7091760 to 23878ec Compare February 21, 2025 21:00
@ParkMyCar ParkMyCar changed the title [dnr][copy_from] Support specifying a column map in COPY ... FROM <url> [copy_from] Support specifying a column map in COPY ... FROM <url> Feb 21, 2025
@ParkMyCar ParkMyCar marked this pull request as ready for review February 21, 2025 21:06
@ParkMyCar ParkMyCar requested review from a team as code owners February 21, 2025 21:06
@ParkMyCar ParkMyCar requested a review from aljoscha February 21, 2025 21:06
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.

1 participant