bulk import

This commit is contained in:
Filipriec
2026-08-21 22:36:41 +02:00
parent 239d43ac1a
commit 0756e99959
9 changed files with 600 additions and 95 deletions

View File

@@ -29,7 +29,7 @@ service TablesData {
rpc PostAccountingTableData(PostAccountingTableDataRequest)
returns (PostTableDataResponse);
// Insert multiple rows by applying PostTableData behavior to each row.
// Insert multiple rows atomically by applying PostTableData behavior to each row.
//
// Behavior:
// - Accepts 1..10,000 rows in one gRPC request
@@ -37,9 +37,27 @@ service TablesData {
// - Each row is inserted through the same validation, script execution,
// typed binding, database insert, and indexing path as PostTableData
// - Stops at the first failing row and returns that row's gRPC error code
// with row index context; rows inserted before the failure remain inserted
// - Commits only when every row succeeds; a failure rolls the entire request back
rpc PostTableDataBulk(PostTableDataBulkRequest) returns (PostTableDataBulkResponse);
// Starts a durable, profile-scoped import staging session. Staging never changes
// profile data; CommitTableDataImport applies every staged chunk atomically.
rpc BeginTableDataImport(BeginTableDataImportRequest)
returns (BeginTableDataImportResponse);
// Adds one table chunk to an import session. Rows retain chunk and table order.
rpc StageTableDataImport(StageTableDataImportRequest)
returns (StageTableDataImportResponse);
// Applies every staged row through the ordinary validated insert machinery in
// one PostgreSQL transaction. Any failure rolls back every imported side effect.
rpc CommitTableDataImport(CommitTableDataImportRequest)
returns (CommitTableDataImportResponse);
// Discards a staged import. Already committed imports cannot be aborted.
rpc AbortTableDataImport(AbortTableDataImportRequest)
returns (AbortTableDataImportResponse);
// Update existing row data with strict type binding and script validation.
//
// Behavior:
@@ -201,6 +219,42 @@ message PostTableDataBulkResponse {
repeated PostTableDataResponse responses = 3;
}
message BeginTableDataImportRequest {
string profile_name = 1;
}
message BeginTableDataImportResponse {
string import_id = 1;
}
message StageTableDataImportRequest {
string import_id = 1;
string table_name = 2;
repeated PostTableDataBulkRow rows = 3;
}
message StageTableDataImportResponse {
int64 staged_rows = 1;
int64 total_staged_rows = 2;
}
message CommitTableDataImportRequest {
string import_id = 1;
}
message CommitTableDataImportResponse {
bool success = 1;
int64 inserted_rows = 2;
}
message AbortTableDataImportRequest {
string import_id = 1;
}
message AbortTableDataImportResponse {
bool success = 1;
}
// Update an existing row.
message PutTableDataRequest {
// Required. Profile (schema) name.