Python API Reference

Complete API reference for the Fluss Python client. For a usage guide with examples, see the Python Client Guide.

Config

Method / PropertyDescription
Config(properties: dict = None)Create config from a dict of key-value pairs
.bootstrap_serverGet/set coordinator server address
.request_max_sizeGet/set max request size in bytes
.writer_batch_sizeGet/set write batch size in bytes

FlussConnection

MethodDescription
await FlussConnection.connect(config) -> FlussConnectionConnect to a Fluss cluster
await conn.get_admin() -> FlussAdminGet admin interface
await conn.get_table(table_path) -> FlussTableGet a table for read/write operations
conn.close()Close the connection

Supports with statement (context manager).

FlussAdmin

MethodDescription
await create_database(name, ignore_if_exists=False, database_descriptor=None)Create a database
await drop_database(name, ignore_if_not_exists=False, cascade=True)Drop a database
await list_databases() -> list[str]List all databases
await database_exists(name) -> boolCheck if a database exists
await get_database_info(name) -> DatabaseInfoGet database metadata
await create_table(table_path, table_descriptor, ignore_if_exists=False)Create a table
await drop_table(table_path, ignore_if_not_exists=False)Drop a table
await get_table(table_path) -> TableInfoGet table metadata
await list_tables(database_name) -> list[str]List tables in a database
await table_exists(table_path) -> boolCheck if a table exists
await list_offsets(table_path, bucket_ids, offset_type, timestamp=None) -> dict[int, int]Get offsets for buckets
await list_partition_offsets(table_path, partition_name, bucket_ids, offset_type, timestamp=None) -> dict[int, int]Get offsets for a partition's buckets
await create_partition(table_path, partition_spec, ignore_if_exists=False)Create a partition
await drop_partition(table_path, partition_spec, ignore_if_not_exists=False)Drop a partition
await list_partition_infos(table_path) -> list[PartitionInfo]List partitions
await get_latest_lake_snapshot(table_path) -> LakeSnapshotGet latest lake snapshot

FlussTable

MethodDescription
new_scan() -> TableScanCreate a scan builder
await new_append_writer() -> AppendWriterCreate writer for log tables
new_upsert(columns=None, column_indices=None) -> UpsertWriterCreate writer for PK tables (optionally partial)
new_lookup() -> LookuperCreate lookuper for PK tables
get_table_info() -> TableInfoGet table metadata
get_table_path() -> TablePathGet table path
has_primary_key() -> boolCheck if table has a primary key

TableScan

MethodDescription
.project(indices) -> TableScanProject columns by index
.project_by_name(names) -> TableScanProject columns by name
await .create_log_scanner() -> LogScannerCreate record-based scanner (for poll())
await .create_batch_scanner() -> LogScannerCreate batch-based scanner (for poll_arrow(), to_arrow(), etc.)

AppendWriter

MethodDescription
.append(row) -> WriteResultHandleAppend a row (dict, list, or tuple)
.write_arrow(table)Write a PyArrow Table
.write_arrow_batch(batch) -> WriteResultHandleWrite a PyArrow RecordBatch
.write_pandas(df)Write a Pandas DataFrame
await .flush()Flush all pending writes

UpsertWriter

MethodDescription
.upsert(row) -> WriteResultHandleUpsert a row (insert or update by PK)
.delete(pk) -> WriteResultHandleDelete a row by primary key
await .flush()Flush all pending operations

WriteResultHandle

MethodDescription
await .wait()Wait for server acknowledgment of this write

Lookuper

MethodDescription
await .lookup(pk) -> dict | NoneLookup a row by primary key

LogScanner

MethodDescription
.subscribe(bucket_id, start_offset)Subscribe to a bucket
.subscribe_buckets(bucket_offsets)Subscribe to multiple buckets ({bucket_id: offset})
.subscribe_partition(partition_id, bucket_id, start_offset)Subscribe to a partition bucket
.subscribe_partition_buckets(partition_bucket_offsets)Subscribe to multiple partition+bucket combos ({(part_id, bucket_id): offset})
.unsubscribe_partition(partition_id, bucket_id)Unsubscribe from a partition bucket
.poll(timeout_ms) -> list[ScanRecord]Poll individual records (record scanner only)
.poll_arrow(timeout_ms) -> pa.TablePoll as Arrow Table (batch scanner only)
.poll_batches(timeout_ms) -> list[RecordBatch]Poll batches with metadata (batch scanner only)
.to_arrow() -> pa.TableRead all subscribed data as Arrow Table (batch scanner only)
.to_pandas() -> pd.DataFrameRead all subscribed data as DataFrame (batch scanner only)

ScanRecord

PropertyDescription
.bucket -> TableBucketBucket this record belongs to
.offset -> intRecord offset in the log
.timestamp -> intRecord timestamp
.change_type -> ChangeTypeChange type (AppendOnly, Insert, UpdateBefore, UpdateAfter, Delete)
.row -> dictRow data as {column_name: value}

RecordBatch

PropertyDescription
.batch -> pa.RecordBatchArrow RecordBatch data
.bucket -> TableBucketBucket this batch belongs to
.base_offset -> intFirst record offset
.last_offset -> intLast record offset

Schema

MethodDescription
Schema(schema: pa.Schema, primary_keys=None)Create from PyArrow schema
.get_column_names() -> list[str]Get column names
.get_column_types() -> list[str]Get column type names

TableDescriptor

MethodDescription
TableDescriptor(schema, *, partition_keys=None, bucket_count=None, bucket_keys=None, comment=None, log_format=None, kv_format=None, properties=None, custom_properties=None)Create table descriptor
.get_schema() -> SchemaGet the schema

TablePath

Method / PropertyDescription
TablePath(database, table)Create a table path
.database_name -> strDatabase name
.table_name -> strTable name

TableInfo

Property / MethodDescription
.table_id -> intTable ID
.table_path -> TablePathTable path
.num_buckets -> intNumber of buckets
.schema_id -> intSchema ID
.comment -> str | NoneTable comment
.created_time -> intCreation timestamp
.modified_time -> intLast modification timestamp
.get_primary_keys() -> list[str]Primary key columns
.get_partition_keys() -> list[str]Partition columns
.get_bucket_keys() -> list[str]Bucket key columns
.has_primary_key() -> boolHas primary key?
.is_partitioned() -> boolIs partitioned?
.get_schema() -> SchemaGet table schema
.get_column_names() -> list[str]Column names
.get_column_count() -> intNumber of columns
.get_properties() -> dictAll table properties
.get_custom_properties() -> dictCustom properties only

PartitionInfo

PropertyDescription
.partition_id -> intPartition ID
.partition_name -> strPartition name

DatabaseDescriptor

Method / PropertyDescription
DatabaseDescriptor(comment=None, custom_properties=None)Create descriptor
.comment -> str | NoneDatabase comment
.get_custom_properties() -> dictCustom properties

DatabaseInfo

Property / MethodDescription
.database_name -> strDatabase name
.created_time -> intCreation timestamp
.modified_time -> intLast modification timestamp
.get_database_descriptor() -> DatabaseDescriptorGet descriptor

LakeSnapshot

Property / MethodDescription
.snapshot_id -> intSnapshot ID
.table_buckets_offset -> dict[TableBucket, int]All bucket offsets
.get_bucket_offset(bucket) -> int | NoneGet offset for a bucket
.get_table_buckets() -> list[TableBucket]Get all buckets

TableBucket

Method / PropertyDescription
TableBucket(table_id, bucket)Create non-partitioned bucket
TableBucket.with_partition(table_id, partition_id, bucket)Create partitioned bucket
.table_id -> intTable ID
.bucket_id -> intBucket ID
.partition_id -> int | NonePartition ID (None if non-partitioned)

FlussError

PropertyDescription
.message -> strError message

Raised for all Fluss-specific errors (connection failures, table not found, schema mismatches, etc.). Inherits from Exception.

Constants

ConstantValueDescription
fluss.EARLIEST_OFFSET-2Start reading from earliest available offset
fluss.LATEST_OFFSET-1Start reading from latest offset (only new records)
fluss.OffsetType.EARLIEST"earliest"For list_offsets()
fluss.OffsetType.LATEST"latest"For list_offsets()
fluss.OffsetType.TIMESTAMP"timestamp"For list_offsets() with timestamp

ChangeType

ValueShort StringDescription
ChangeType.AppendOnly (0)+AAppend-only
ChangeType.Insert (1)+IInsert
ChangeType.UpdateBefore (2)-UPrevious value of updated row
ChangeType.UpdateAfter (3)+UNew value of updated row
ChangeType.Delete (4)-DDelete

Data Types

PyArrow TypeFluss TypePython Type
pa.boolean()Booleanbool
pa.int8() / int16() / int32() / int64()TinyInt / SmallInt / Int / BigIntint
pa.float32() / float64()Float / Doublefloat
pa.string()Stringstr
pa.binary()Bytesbytes
pa.date32()Datedatetime.date
pa.time32("ms")Timedatetime.time
pa.timestamp("us")Timestamp (NTZ)datetime.datetime
pa.timestamp("us", tz="UTC")TimestampLTZdatetime.datetime
pa.decimal128(precision, scale)Decimaldecimal.Decimal