Skip to content

Commit 75db8f8

Browse files
authored
Merge pull request #7251 from keboola/zajca/table-swap
feat(storage): add table swap operation
2 parents 487b22a + 2702245 commit 75db8f8

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/Keboola/StorageApi/Client.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,6 +1430,27 @@ public function dropTable($tableId, $options = ['async' => true])
14301430
return $result;
14311431
}
14321432

1433+
/**
1434+
* Swap two tables. Aliases are not transferred — they keep pointing at
1435+
* the same physical position, so after the swap they expose the data of
1436+
* the other table.
1437+
*
1438+
* @return array<string, mixed>
1439+
*/
1440+
public function swapTables(string $tableId, string $targetTableId): array
1441+
{
1442+
if (!$this instanceof BranchAwareClient) {
1443+
throw new ClientException('Swapping tables is supported only in dev branch. Use BranchAwareClient instance.');
1444+
}
1445+
1446+
/** @var array<string, mixed> $result */
1447+
$result = $this->apiPostJson("tables/{$tableId}/swap", [
1448+
'targetTableId' => $targetTableId,
1449+
]);
1450+
$this->log("Table {$tableId} swapped with {$targetTableId}");
1451+
return $result;
1452+
}
1453+
14331454
/**
14341455
*
14351456
* Add column to table

0 commit comments

Comments
 (0)