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

fix: implement transaction identifiers #24

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion crates/core/src/table/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl ReplayVisitor for AppTransactionVisitor {
let app = ex::read_str(id, idx)?;
let version = ex::read_primitive(version, idx)?;

self.app_transaction_version.insert(app.to_owned(), version);
self.app_transaction_version.entry(app.to_owned()).or_insert(version);
}

Ok(())
Expand Down
21 changes: 21 additions & 0 deletions crates/core/tests/checkpoint_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ mod simple_checkpoint {
.await
.unwrap();

let transactions = table.get_app_transaction_version();
assert_eq!(transactions.get("appId-1").cloned(), Some(11));
assert_eq!(transactions.get("appId-2").cloned(), Some(12));
assert_eq!(transactions.get("appId-3"), None);
assert_eq!(transactions.get("appId-4"), None);

// Write a checkpoint
checkpoints::create_checkpoint(&table).await.unwrap();

Expand All @@ -38,6 +44,14 @@ mod simple_checkpoint {
table.load_version(10).await.unwrap();
checkpoints::create_checkpoint(&table).await.unwrap();

println!("{:?}", table.get_app_transaction_version());

let transactions = table.get_app_transaction_version();
assert_eq!(transactions.get("appId-1").cloned(), Some(17));
assert_eq!(transactions.get("appId-2").cloned(), Some(18));
assert_eq!(transactions.get("appId-3").cloned(), Some(3));
assert_eq!(transactions.get("appId-4").cloned(), Some(4));

// checkpoint should exist
let checkpoint_path = log_path.join("00000000000000000010.checkpoint.parquet");
assert!(checkpoint_path.as_path().exists());
Expand All @@ -49,6 +63,13 @@ mod simple_checkpoint {
// delta table should load just fine with the checkpoint in place
let table_result = deltalake_core::open_table(table_location).await.unwrap();
let table = table_result;

let transactions = table.get_app_transaction_version();
assert_eq!(transactions.get("appId-1").cloned(), Some(17));
assert_eq!(transactions.get("appId-2").cloned(), Some(18));
assert_eq!(transactions.get("appId-3").cloned(), Some(7));
assert_eq!(transactions.get("appId-4").cloned(), Some(7));

let files = table.get_files_iter().unwrap();
assert_eq!(12, files.count());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{"txn":{"appId":"appId-1","version":1,"lastUpdated":1627668675695}}
{"txn":{"appId":"appId-2","version":2,"lastUpdated":1627668675695}}
{"commitInfo":{"timestamp":1627668675695,"userId":"100011","userName":"christianw@scribd.com","operation":"CREATE TABLE","operationParameters":{"isManaged":"false","description":null,"partitionBy":"[\"date\"]","properties":"{}"},"notebook":{"notebookId":"746418"},"clusterId":"0416-131918-rebus430","isolationLevel":"SnapshotIsolation","isBlindAppend":true,"operationMetrics":{}}}
{"protocol":{"minReaderVersion":1,"minWriterVersion":2}}
{"metaData":{"id":"853536c9-0abe-4e66-9732-1718e542e6aa","format":{"provider":"parquet","options":{}},"schemaString":"{\"type\":\"struct\",\"fields\":[{\"name\":\"some_struct\",\"type\":{\"type\":\"struct\",\"fields\":[{\"name\":\"some_struct_member\",\"type\":\"string\",\"nullable\":true,\"metadata\":{}},{\"name\":\"some_struct_timestamp\",\"type\":\"timestamp\",\"nullable\":true,\"metadata\":{}}]},\"nullable\":true,\"metadata\":{}},{\"name\":\"value\",\"type\":\"string\",\"nullable\":true,\"metadata\":{}},{\"name\":\"ts\",\"type\":\"timestamp\",\"nullable\":true,\"metadata\":{}},{\"name\":\"date\",\"type\":\"string\",\"nullable\":true,\"metadata\":{}}]}","partitionColumns":["date"],"configuration":{},"createdTime":1627668675432}}
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
{"txn":{"appId":"appId-1","version":3,"lastUpdated":1627668685528}}
{"txn":{"appId":"appId-2","version":4,"lastUpdated":1627668685528}}
{"commitInfo":{"timestamp":1627668685528,"userId":"100011","userName":"christianw@scribd.com","operation":"WRITE","operationParameters":{"mode":"Append","partitionBy":"[]"},"notebook":{"notebookId":"746418"},"clusterId":"0416-131918-rebus430","readVersion":0,"isolationLevel":"WriteSerializable","isBlindAppend":true,"operationMetrics":{"numFiles":"1","numOutputBytes":"1502","numOutputRows":"1"}}}
{"add":{"path":"date=2020-06-01/part-00000-b207ef5f-4458-4969-bd34-46439cdeb6a6.c000.snappy.parquet","partitionValues":{"date":"2020-06-01"},"size":1502,"modificationTime":1627668686000,"dataChange":true,"stats":"{\"numRecords\":1,\"minValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:24.594Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:24.594Z\"},\"maxValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:24.594Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:24.594Z\"},\"nullCount\":{\"some_struct\":{\"some_struct_member\":0,\"some_struct_timestamp\":0},\"value\":0,\"ts\":0}}"}}
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
{"txn":{"appId":"appId-1","version":5,"lastUpdated":1627668687609}}
{"txn":{"appId":"appId-2","version":6,"lastUpdated":1627668687609}}
{"commitInfo":{"timestamp":1627668687609,"userId":"100011","userName":"christianw@scribd.com","operation":"WRITE","operationParameters":{"mode":"Append","partitionBy":"[]"},"notebook":{"notebookId":"746418"},"clusterId":"0416-131918-rebus430","readVersion":1,"isolationLevel":"WriteSerializable","isBlindAppend":true,"operationMetrics":{"numFiles":"1","numOutputBytes":"1502","numOutputRows":"1"}}}
{"add":{"path":"date=2020-06-01/part-00000-762e2b03-6a04-4707-b676-5d38d1ef9fca.c000.snappy.parquet","partitionValues":{"date":"2020-06-01"},"size":1502,"modificationTime":1627668688000,"dataChange":true,"stats":"{\"numRecords\":1,\"minValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:27.001Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:27.001Z\"},\"maxValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:27.001Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:27.001Z\"},\"nullCount\":{\"some_struct\":{\"some_struct_member\":0,\"some_struct_timestamp\":0},\"value\":0,\"ts\":0}}"}}
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
{"txn":{"appId":"appId-1","version":7,"lastUpdated":1627668691354}}
{"txn":{"appId":"appId-2","version":8,"lastUpdated":1627668691354}}
{"commitInfo":{"timestamp":1627668691354,"userId":"100011","userName":"christianw@scribd.com","operation":"WRITE","operationParameters":{"mode":"Append","partitionBy":"[]"},"notebook":{"notebookId":"746418"},"clusterId":"0416-131918-rebus430","readVersion":2,"isolationLevel":"WriteSerializable","isBlindAppend":true,"operationMetrics":{"numFiles":"1","numOutputBytes":"1502","numOutputRows":"1"}}}
{"add":{"path":"date=2020-06-01/part-00000-ca044815-1585-4e08-aa15-904c5ec961e6.c000.snappy.parquet","partitionValues":{"date":"2020-06-01"},"size":1502,"modificationTime":1627668691000,"dataChange":true,"stats":"{\"numRecords\":1,\"minValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:29.919Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:29.919Z\"},\"maxValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:29.919Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:29.919Z\"},\"nullCount\":{\"some_struct\":{\"some_struct_member\":0,\"some_struct_timestamp\":0},\"value\":0,\"ts\":0}}"}}
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
{"txn":{"appId":"appId-1","version":9,"lastUpdated":1627668694198}}
{"txn":{"appId":"appId-2","version":10,"lastUpdated":1627668694198}}
{"commitInfo":{"timestamp":1627668694198,"userId":"100011","userName":"christianw@scribd.com","operation":"WRITE","operationParameters":{"mode":"Append","partitionBy":"[]"},"notebook":{"notebookId":"746418"},"clusterId":"0416-131918-rebus430","readVersion":3,"isolationLevel":"WriteSerializable","isBlindAppend":true,"operationMetrics":{"numFiles":"1","numOutputBytes":"1502","numOutputRows":"1"}}}
{"add":{"path":"date=2020-06-01/part-00000-ee6161de-c5be-4117-9ffe-e09b7475dbc7.c000.snappy.parquet","partitionValues":{"date":"2020-06-01"},"size":1502,"modificationTime":1627668694000,"dataChange":true,"stats":"{\"numRecords\":1,\"minValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:33.223Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:33.223Z\"},\"maxValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:33.223Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:33.223Z\"},\"nullCount\":{\"some_struct\":{\"some_struct_member\":0,\"some_struct_timestamp\":0},\"value\":0,\"ts\":0}}"}}
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
{"txn":{"appId":"appId-1","version":11,"lastUpdated":1627668697887}}
{"txn":{"appId":"appId-2","version":12,"lastUpdated":1627668697887}}
{"commitInfo":{"timestamp":1627668697887,"userId":"100011","userName":"christianw@scribd.com","operation":"WRITE","operationParameters":{"mode":"Append","partitionBy":"[]"},"notebook":{"notebookId":"746418"},"clusterId":"0416-131918-rebus430","readVersion":4,"isolationLevel":"WriteSerializable","isBlindAppend":true,"operationMetrics":{"numFiles":"1","numOutputBytes":"1502","numOutputRows":"1"}}}
{"add":{"path":"date=2020-06-01/part-00000-c7966c2b-09de-499d-8a90-5694ade6d659.c000.snappy.parquet","partitionValues":{"date":"2020-06-01"},"size":1502,"modificationTime":1627668698000,"dataChange":true,"stats":"{\"numRecords\":1,\"minValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:36.588Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:36.588Z\"},\"maxValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:36.588Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:36.588Z\"},\"nullCount\":{\"some_struct\":{\"some_struct_member\":0,\"some_struct_timestamp\":0},\"value\":0,\"ts\":0}}"}}
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
{"txn":{"appId":"appId-1","version":13,"lastUpdated":1627668700090}}
{"txn":{"appId":"appId-2","version":14,"lastUpdated":1627668700090}}
{"commitInfo":{"timestamp":1627668700090,"userId":"100011","userName":"christianw@scribd.com","operation":"WRITE","operationParameters":{"mode":"Append","partitionBy":"[]"},"notebook":{"notebookId":"746418"},"clusterId":"0416-131918-rebus430","readVersion":5,"isolationLevel":"WriteSerializable","isBlindAppend":true,"operationMetrics":{"numFiles":"1","numOutputBytes":"1502","numOutputRows":"1"}}}
{"add":{"path":"date=2020-06-01/part-00000-ce9ff441-1618-489a-8810-301d2a3fa32d.c000.snappy.parquet","partitionValues":{"date":"2020-06-01"},"size":1502,"modificationTime":1627668700000,"dataChange":true,"stats":"{\"numRecords\":1,\"minValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:39.466Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:39.466Z\"},\"maxValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:39.466Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:39.466Z\"},\"nullCount\":{\"some_struct\":{\"some_struct_member\":0,\"some_struct_timestamp\":0},\"value\":0,\"ts\":0}}"}}
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
{"txn":{"appId":"appId-3","version":1,"lastUpdated":1627668702166}}
{"txn":{"appId":"appId-4","version":2,"lastUpdated":1627668702166}}
{"commitInfo":{"timestamp":1627668702166,"userId":"100011","userName":"christianw@scribd.com","operation":"WRITE","operationParameters":{"mode":"Append","partitionBy":"[]"},"notebook":{"notebookId":"746418"},"clusterId":"0416-131918-rebus430","readVersion":6,"isolationLevel":"WriteSerializable","isBlindAppend":true,"operationMetrics":{"numFiles":"1","numOutputBytes":"1502","numOutputRows":"1"}}}
{"add":{"path":"date=2020-06-02/part-00000-696c78e6-3b86-4bd1-94a7-b1ec40eafe76.c000.snappy.parquet","partitionValues":{"date":"2020-06-02"},"size":1502,"modificationTime":1627668703000,"dataChange":true,"stats":"{\"numRecords\":1,\"minValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:41.530Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:41.530Z\"},\"maxValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:41.530Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:41.530Z\"},\"nullCount\":{\"some_struct\":{\"some_struct_member\":0,\"some_struct_timestamp\":0},\"value\":0,\"ts\":0}}"}}
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
{"txn":{"appId":"appId-3","version":3,"lastUpdated":1627668704299}}
{"txn":{"appId":"appId-4","version":4,"lastUpdated":1627668704299}}
{"commitInfo":{"timestamp":1627668704299,"userId":"100011","userName":"christianw@scribd.com","operation":"WRITE","operationParameters":{"mode":"Append","partitionBy":"[]"},"notebook":{"notebookId":"746418"},"clusterId":"0416-131918-rebus430","readVersion":7,"isolationLevel":"WriteSerializable","isBlindAppend":true,"operationMetrics":{"numFiles":"1","numOutputBytes":"1502","numOutputRows":"1"}}}
{"add":{"path":"date=2020-06-02/part-00000-1c6c1825-ee0e-4f44-a3e8-73245adcea35.c000.snappy.parquet","partitionValues":{"date":"2020-06-02"},"size":1502,"modificationTime":1627668705000,"dataChange":true,"stats":"{\"numRecords\":1,\"minValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:43.665Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:43.665Z\"},\"maxValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:43.665Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:43.665Z\"},\"nullCount\":{\"some_struct\":{\"some_struct_member\":0,\"some_struct_timestamp\":0},\"value\":0,\"ts\":0}}"}}
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
{"txn":{"appId":"appId-1","version":15,"lastUpdated":1627668707512}}
{"txn":{"appId":"appId-2","version":16,"lastUpdated":1627668707512}}
{"commitInfo":{"timestamp":1627668707512,"userId":"100011","userName":"christianw@scribd.com","operation":"WRITE","operationParameters":{"mode":"Append","partitionBy":"[]"},"notebook":{"notebookId":"746418"},"clusterId":"0416-131918-rebus430","readVersion":8,"isolationLevel":"WriteSerializable","isBlindAppend":true,"operationMetrics":{"numFiles":"1","numOutputBytes":"1502","numOutputRows":"1"}}}
{"add":{"path":"date=2020-06-03/part-00000-2d0a97a0-62a6-415e-b598-1479e361f91f.c000.snappy.parquet","partitionValues":{"date":"2020-06-03"},"size":1502,"modificationTime":1627668708000,"dataChange":true,"stats":"{\"numRecords\":1,\"minValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:46.831Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:46.831Z\"},\"maxValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:46.831Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:46.831Z\"},\"nullCount\":{\"some_struct\":{\"some_struct_member\":0,\"some_struct_timestamp\":0},\"value\":0,\"ts\":0}}"}}
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
{"txn":{"appId":"appId-1","version":17,"lastUpdated":1627668709513}}
{"txn":{"appId":"appId-2","version":18,"lastUpdated":1627668709513}}
{"commitInfo":{"timestamp":1627668709513,"userId":"100011","userName":"christianw@scribd.com","operation":"WRITE","operationParameters":{"mode":"Append","partitionBy":"[]"},"notebook":{"notebookId":"746418"},"clusterId":"0416-131918-rebus430","readVersion":9,"isolationLevel":"WriteSerializable","isBlindAppend":true,"operationMetrics":{"numFiles":"1","numOutputBytes":"1502","numOutputRows":"1"}}}
{"add":{"path":"date=2020-06-03/part-00000-c3f3c634-9695-4cc1-b76d-0f5feb30f278.c000.snappy.parquet","partitionValues":{"date":"2020-06-03"},"size":1502,"modificationTime":1627668710000,"dataChange":true,"stats":"{\"numRecords\":1,\"minValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:48.919Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:48.920Z\"},\"maxValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:48.919Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:48.920Z\"},\"nullCount\":{\"some_struct\":{\"some_struct_member\":0,\"some_struct_timestamp\":0},\"value\":0,\"ts\":0}}"}}
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
{"txn":{"appId":"appId-3","version":5,"lastUpdated":1627668712228}}
{"txn":{"appId":"appId-4","version":6,"lastUpdated":1627668712228}}
{"commitInfo":{"timestamp":1627668712228,"userId":"100011","userName":"christianw@scribd.com","operation":"WRITE","operationParameters":{"mode":"Append","partitionBy":"[]"},"notebook":{"notebookId":"746418"},"clusterId":"0416-131918-rebus430","readVersion":10,"isolationLevel":"WriteSerializable","isBlindAppend":true,"operationMetrics":{"numFiles":"1","numOutputBytes":"1502","numOutputRows":"1"}}}
{"add":{"path":"date=2020-06-03/part-00000-187631a9-ef68-445e-9e78-b03451ebd63f.c000.snappy.parquet","partitionValues":{"date":"2020-06-03"},"size":1502,"modificationTime":1627668713000,"dataChange":true,"stats":"{\"numRecords\":1,\"minValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:51.626Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:51.626Z\"},\"maxValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:51.626Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:51.626Z\"},\"nullCount\":{\"some_struct\":{\"some_struct_member\":0,\"some_struct_timestamp\":0},\"value\":0,\"ts\":0}}"}}
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
{"txn":{"appId":"appId-3","version":7,"lastUpdated":1627668712228}}
{"txn":{"appId":"appId-4","version":7,"lastUpdated":1627668712228}}
{"commitInfo":{"timestamp":1627668712228,"userId":"100011","userName":"christianw@scribd.com","operation":"WRITE","operationParameters":{"mode":"Append","partitionBy":"[]"},"notebook":{"notebookId":"746418"},"clusterId":"0416-131918-rebus430","readVersion":10,"isolationLevel":"WriteSerializable","isBlindAppend":true,"operationMetrics":{"numFiles":"1","numOutputBytes":"1502","numOutputRows":"1"}}}
{"add":{"path":"date=2020-06-03/part-00000-69e74256-615d-49cc-94c8-a02826bd4221.c000.snappy.parquet","partitionValues":{"date":"2020-06-03"},"size":1502,"modificationTime":1627668713000,"dataChange":true,"stats":"{\"numRecords\":1,\"minValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:51.626Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:51.626Z\"},\"maxValues\":{\"some_struct\":{\"some_struct_member\":\"x\",\"some_struct_timestamp\":\"2021-07-30T18:11:51.626Z\"},\"value\":\"x\",\"ts\":\"2021-07-30T18:11:51.626Z\"},\"nullCount\":{\"some_struct\":{\"some_struct_member\":0,\"some_struct_timestamp\":0},\"value\":0,\"ts\":0}}"}}
Loading