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

materialize-databricks: reset needsMerge flag after each transaction #2425

Merged
merged 2 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ jobs:
]'), matrix.connector)
env:
GCP_SERVICE_ACCOUNT_KEY: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
ROCKSET_API_KEY: ${{ secrets.ROCKSET_API_KEY }}
MYSQL_DATABASE: test

run: CONNECTOR=${{ matrix.connector }} VERSION=local ./tests/run.sh;
Expand Down Expand Up @@ -285,8 +284,6 @@ jobs:
"materialize-redshift",
"materialize-s3-iceberg"
]'), matrix.connector)
env:
GCP_SERVICE_ACCOUNT_KEY: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}

run: CONNECTOR=${{ matrix.connector }} VERSION=local tests/materialize/run.sh;

Expand Down
1 change: 1 addition & 0 deletions materialize-databricks/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ func (d *transactor) Store(it *m.StoreIterator) (_ m.StartCommitFunc, err error)
Queries: queries,
ToDelete: fullPaths,
}
b.needsMerge = false // reset for next round
}

return func(ctx context.Context, runtimeCheckpoint *protocol.Checkpoint) (*pf.ConnectorState, m.OpFuture) {
Expand Down
6 changes: 4 additions & 2 deletions materialize-sqlserver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,10 @@ func (d *transactor) Store(it *m.StoreIterator) (_ m.StartCommitFunc, err error)
}
}

if _, err := batches[lastBinding].ExecContext(ctx); err != nil {
return nil, fmt.Errorf("store batch insert on %q: %w", d.bindings[lastBinding].tempStoreTableName, err)
if lastBinding != -1 {
if _, err := batches[lastBinding].ExecContext(ctx); err != nil {
return nil, fmt.Errorf("store batch insert on %q: %w", d.bindings[lastBinding].tempStoreTableName, err)
}
}

return func(ctx context.Context, runtimeCheckpoint *protocol.Checkpoint) (*pf.ConnectorState, m.OpFuture) {
Expand Down
8 changes: 8 additions & 0 deletions tests/materialize/fixture.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[
[],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this initial empty transaction for unrelated reasons since I was updating all the test snapshots anyway (see commit message) - note that this causes the materialized timestamps to shift up for the subsequent transactions, which accounts for a lot of the diff in the snapshots.

[
["tests/simple", { "id": 1, "canary": "amputation's"}],
["tests/simple", { "id": 2, "canary": "armament's"}],
Expand Down Expand Up @@ -81,5 +82,12 @@
["tests/deletions", { "id": 4, "_meta": {"op": "d"} }],

["tests/binary-key", { "id": "c2F5xY1uYXJhCg==", "counter": 1 }]
],
[
["tests/duplicated-keys", { "id": 6, "int": 11, "str": "str 11"}],
["tests/duplicated-keys", { "id": 7, "int": 12, "str": "str 12"}],
["tests/duplicated-keys", { "id": 8, "int": 13, "str": "str 13"}],
["tests/duplicated-keys", { "id": 9, "int": 14, "str": "str 14"}],
["tests/duplicated-keys", { "id": 10, "int": 15, "str": "str 15"}]
]
]
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func main() {
os.Exit(0)
}

rows, err := db.Query(fmt.Sprintf(`SELECT * FROM %q.%q ORDER BY id`, schema, tables[0]))
rows, err := db.Query(fmt.Sprintf(`SELECT * FROM %q.%q ORDER BY id, flow_published_at`, schema, tables[0]))
if err != nil {
log.Fatal(fmt.Errorf("running query: %w", err))
}
Expand Down
Loading
Loading