Branch Statement Builders

SQLAlchemy-style statement builders for branch operations.

Top-Level Functions

matrixone.branch_builder.create_table_branch(target_table: str | Type) CreateTableBranch[source]

Build a CREATE TABLE BRANCH statement.

Example:

stmt = create_table_branch('dev').from_table('prod', snapshot='snap1')
client.execute(str(stmt))
matrixone.branch_builder.create_database_branch(target_db: str) CreateDatabaseBranch[source]

Build a CREATE DATABASE BRANCH statement.

Example:

stmt = create_database_branch('dev_db').from_database('prod_db')
client.execute(str(stmt))
matrixone.branch_builder.delete_table_branch(table: str | Type) DeleteTableBranch[source]

Build a DELETE TABLE BRANCH statement.

Example:

stmt = delete_table_branch('branch_table')
client.execute(str(stmt))
matrixone.branch_builder.delete_database_branch(database: str) DeleteDatabaseBranch[source]

Build a DELETE DATABASE BRANCH statement.

Example:

stmt = delete_database_branch('branch_db')
client.execute(str(stmt))
matrixone.branch_builder.diff_table_branch(target_table: str | Type) DiffTableBranch[source]

Build a DIFF TABLE BRANCH statement.

Example:

stmt = diff_table_branch('t1').against('t2').output_count()
client.execute(str(stmt))
matrixone.branch_builder.merge_table_branch(source_table: str | Type) MergeTableBranch[source]

Build a MERGE TABLE BRANCH statement.

Example:

stmt = merge_table_branch('source').into('target').when_conflict('accept')
client.execute(str(stmt))

Statement Classes

class matrixone.branch_builder.BranchStatement[source]

Base class for branch statements.

These are NOT SQLAlchemy ClauseElements. They produce raw SQL strings via compile() and should be executed as: client.execute(str(stmt))

compile() str[source]

Compile to SQL string.

class matrixone.branch_builder.CreateTableBranch(target_table: str | Type)[source]

CREATE TABLE BRANCH statement builder.

__init__(target_table: str | Type)[source]
from_table(source: str | Type, snapshot: str | None = None) CreateTableBranch[source]

Set source table and optional snapshot.

to_account(account: str) CreateTableBranch[source]

Set target account for cross-tenant branching (sys tenant only).

compile() str[source]

Compile to SQL string.

class matrixone.branch_builder.CreateDatabaseBranch(target_db: str)[source]

CREATE DATABASE BRANCH statement builder.

__init__(target_db: str)[source]
from_database(source: str, snapshot: str | None = None) CreateDatabaseBranch[source]

Set source database and optional snapshot.

to_account(account: str) CreateDatabaseBranch[source]

Set target account for cross-tenant branching (sys tenant only).

compile() str[source]

Compile to SQL string.

class matrixone.branch_builder.DeleteTableBranch(table: str | Type)[source]

DELETE TABLE BRANCH statement builder.

__init__(table: str | Type)[source]
compile() str[source]

Compile to SQL string.

class matrixone.branch_builder.DeleteDatabaseBranch(database: str)[source]

DELETE DATABASE BRANCH statement builder.

__init__(database: str)[source]
compile() str[source]

Compile to SQL string.

class matrixone.branch_builder.DiffTableBranch(target_table: str | Type)[source]

DIFF TABLE BRANCH statement builder.

__init__(target_table: str | Type)[source]
snapshot(name: str) DiffTableBranch[source]

Set snapshot for target table.

against(base: str | Type, snapshot: str | None = None) DiffTableBranch[source]

Set base table to compare against.

output_count() DiffTableBranch[source]

Output only count of differences.

output_limit(limit: int) DiffTableBranch[source]

Limit returned difference rows.

output_file(path: str) DiffTableBranch[source]

Export differences to file (local path or stage:// URL).

output_as(table_name: str) DiffTableBranch[source]

Save differences to table (not yet supported by MatrixOne).

compile() str[source]

Compile to SQL string.

class matrixone.branch_builder.MergeTableBranch(source_table: str | Type)[source]

MERGE TABLE BRANCH statement builder.

__init__(source_table: str | Type)[source]
into(target: str | Type) MergeTableBranch[source]

Set target table to merge into.

when_conflict(strategy: str | MergeConflictStrategy) MergeTableBranch[source]

Set conflict resolution strategy: ‘skip’ or ‘accept’.

compile() str[source]

Compile to SQL string.

Enums

class matrixone.branch_builder.DiffOutputOption(value)[source]

Diff output format options

COUNT = 'count'
LIMIT = 'limit'
FILE = 'file'
AS = 'as'
__format__(format_spec)

Returns format using actual value type unless __str__ has been overridden.