-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy path__init__.pyi
More file actions
1000 lines (869 loc) · 33.3 KB
/
__init__.pyi
File metadata and controls
1000 lines (869 loc) · 33.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
"""Type stubs for Fluss Python bindings."""
from enum import IntEnum
from types import TracebackType
from typing import Dict, Iterator, List, Optional, Tuple, Union, overload
import pandas as pd
import pyarrow as pa
class ChangeType(IntEnum):
"""Represents the type of change for a record in a log."""
AppendOnly = 0
"""Append-only operation"""
Insert = 1
"""Insert operation"""
UpdateBefore = 2
"""Update operation containing the previous content of the updated row"""
UpdateAfter = 3
"""Update operation containing the new content of the updated row"""
Delete = 4
"""Delete operation"""
def short_string(self) -> str:
"""Returns a short string representation (+A, +I, -U, +U, -D)."""
...
class ScanRecord:
"""Represents a single scan record with metadata.
The bucket is the key in ScanRecords, not on the individual record
(matches Rust/Java).
"""
@property
def offset(self) -> int:
"""The position of this record in the log."""
...
@property
def timestamp(self) -> int:
"""The timestamp of this record."""
...
@property
def change_type(self) -> ChangeType:
"""The type of change (insert, update, delete, etc.)."""
...
@property
def row(self) -> Dict[str, object]:
"""The row data as a dictionary mapping column names to values."""
...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
class RecordBatch:
"""Represents a batch of records with metadata."""
@property
def batch(self) -> pa.RecordBatch:
"""The Arrow RecordBatch containing the data."""
...
@property
def bucket(self) -> TableBucket:
"""The bucket this batch belongs to."""
...
@property
def base_offset(self) -> int:
"""The offset of the first record in this batch."""
...
@property
def last_offset(self) -> int:
"""The offset of the last record in this batch."""
...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
class ScanRecords:
"""A collection of scan records grouped by bucket.
Returned by ``LogScanner.poll()``. Supports flat iteration
(``for rec in records``) and per-bucket access (``records.records(bucket)``).
"""
def buckets(self) -> List[TableBucket]:
"""List of distinct buckets that have records."""
...
def records(self, bucket: TableBucket) -> List[ScanRecord]:
"""Get records for a specific bucket. Returns empty list if bucket not present."""
...
def count(self) -> int:
"""Total number of records across all buckets."""
...
def is_empty(self) -> bool:
"""Whether the result set is empty."""
...
def keys(self) -> List[TableBucket]:
"""Mapping protocol: alias for ``buckets()``."""
...
def values(self) -> Iterator[List[ScanRecord]]:
"""Mapping protocol: lazy iterator over record lists, one per bucket."""
...
def items(self) -> Iterator[Tuple[TableBucket, List[ScanRecord]]]:
"""Mapping protocol: lazy iterator over ``(bucket, records)`` pairs."""
...
def __len__(self) -> int: ...
@overload
def __getitem__(self, index: int) -> ScanRecord: ...
@overload
def __getitem__(self, index: slice) -> List[ScanRecord]: ...
@overload
def __getitem__(self, bucket: TableBucket) -> List[ScanRecord]: ...
def __getitem__(self, key: Union[int, slice, TableBucket]) -> Union[ScanRecord, List[ScanRecord]]: ...
def __contains__(self, bucket: TableBucket) -> bool: ...
def __iter__(self) -> Iterator[ScanRecord]: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
class Config:
def __init__(self, properties: Optional[Dict[str, str]] = None) -> None: ...
@property
def bootstrap_servers(self) -> str: ...
@bootstrap_servers.setter
def bootstrap_servers(self, server: str) -> None: ...
@property
def writer_request_max_size(self) -> int: ...
@writer_request_max_size.setter
def writer_request_max_size(self, size: int) -> None: ...
@property
def writer_acks(self) -> str: ...
@writer_acks.setter
def writer_acks(self, acks: str) -> None: ...
@property
def writer_retries(self) -> int: ...
@writer_retries.setter
def writer_retries(self, retries: int) -> None: ...
@property
def writer_batch_size(self) -> int: ...
@writer_batch_size.setter
def writer_batch_size(self, size: int) -> None: ...
@property
def writer_bucket_no_key_assigner(self) -> str: ...
@writer_bucket_no_key_assigner.setter
def writer_bucket_no_key_assigner(self, value: str) -> None: ...
@property
def scanner_remote_log_prefetch_num(self) -> int: ...
@scanner_remote_log_prefetch_num.setter
def scanner_remote_log_prefetch_num(self, num: int) -> None: ...
@property
def remote_file_download_thread_num(self) -> int: ...
@remote_file_download_thread_num.setter
def remote_file_download_thread_num(self, num: int) -> None: ...
@property
def scanner_remote_log_read_concurrency(self) -> int: ...
@scanner_remote_log_read_concurrency.setter
def scanner_remote_log_read_concurrency(self, num: int) -> None: ...
@property
def scanner_log_max_poll_records(self) -> int: ...
@scanner_log_max_poll_records.setter
def scanner_log_max_poll_records(self, num: int) -> None: ...
@property
def request_timeout_ms(self) -> int: ...
@request_timeout_ms.setter
def request_timeout_ms(self, timeout: int) -> None: ...
@property
def scanner_log_fetch_max_bytes(self) -> int: ...
@scanner_log_fetch_max_bytes.setter
def scanner_log_fetch_max_bytes(self, bytes: int) -> None: ...
@property
def scanner_log_fetch_min_bytes(self) -> int: ...
@scanner_log_fetch_min_bytes.setter
def scanner_log_fetch_min_bytes(self, bytes: int) -> None: ...
@property
def scanner_log_fetch_wait_max_time_ms(self) -> int: ...
@scanner_log_fetch_wait_max_time_ms.setter
def scanner_log_fetch_wait_max_time_ms(self, ms: int) -> None: ...
@property
def scanner_log_fetch_max_bytes_for_bucket(self) -> int: ...
@scanner_log_fetch_max_bytes_for_bucket.setter
def scanner_log_fetch_max_bytes_for_bucket(self, bytes: int) -> None: ...
@property
def writer_batch_timeout_ms(self) -> int: ...
@writer_batch_timeout_ms.setter
def writer_batch_timeout_ms(self, timeout: int) -> None: ...
@property
def connect_timeout_ms(self) -> int: ...
@connect_timeout_ms.setter
def connect_timeout_ms(self, timeout: int) -> None: ...
@property
def security_protocol(self) -> str: ...
@security_protocol.setter
def security_protocol(self, protocol: str) -> None: ...
@property
def security_sasl_mechanism(self) -> str: ...
@security_sasl_mechanism.setter
def security_sasl_mechanism(self, mechanism: str) -> None: ...
@property
def security_sasl_username(self) -> str: ...
@security_sasl_username.setter
def security_sasl_username(self, username: str) -> None: ...
@property
def security_sasl_password(self) -> str: ...
@security_sasl_password.setter
def security_sasl_password(self, password: str) -> None: ...
class FlussConnection:
@staticmethod
async def create(config: Config) -> FlussConnection: ...
async def get_admin(self) -> FlussAdmin: ...
async def get_table(self, table_path: TablePath) -> FlussTable: ...
def close(self) -> None: ...
def __enter__(self) -> FlussConnection: ...
def __exit__(
self,
exc_type: Optional[type],
exc_value: Optional[BaseException],
traceback: Optional[TracebackType],
) -> bool: ...
def __repr__(self) -> str: ...
class ServerNode:
"""Information about a server node in the Fluss cluster."""
@property
def id(self) -> int:
"""The server node ID."""
...
@property
def host(self) -> str:
"""The hostname of the server."""
...
@property
def port(self) -> int:
"""The port number of the server."""
...
@property
def server_type(self) -> str:
"""The type of server ('CoordinatorServer' or 'TabletServer')."""
...
@property
def uid(self) -> str:
"""The unique identifier of the server (e.g. 'cs-0', 'ts-1')."""
...
def __repr__(self) -> str: ...
class FlussAdmin:
async def create_database(
self,
database_name: str,
database_descriptor: Optional["DatabaseDescriptor"] = None,
ignore_if_exists: bool = False,
) -> None:
"""Create a database."""
...
async def drop_database(
self,
database_name: str,
ignore_if_not_exists: bool = False,
cascade: bool = True,
) -> None:
"""Drop a database."""
...
async def list_databases(self) -> List[str]:
"""List all databases."""
...
async def database_exists(self, database_name: str) -> bool:
"""Check if a database exists."""
...
async def get_database_info(self, database_name: str) -> "DatabaseInfo":
"""Get database information."""
...
async def list_tables(self, database_name: str) -> List[str]:
"""List all tables in a database."""
...
async def table_exists(self, table_path: TablePath) -> bool:
"""Check if a table exists."""
...
async def drop_partition(
self,
table_path: TablePath,
partition_spec: Dict[str, str],
ignore_if_not_exists: bool = False,
) -> None:
"""Drop a partition from a partitioned table."""
...
async def create_table(
self,
table_path: TablePath,
table_descriptor: TableDescriptor,
ignore_if_exists: Optional[bool] = False,
) -> None: ...
async def get_table_info(self, table_path: TablePath) -> TableInfo: ...
async def get_latest_lake_snapshot(self, table_path: TablePath) -> LakeSnapshot: ...
async def drop_table(
self,
table_path: TablePath,
ignore_if_not_exists: bool = False,
) -> None: ...
async def list_offsets(
self,
table_path: TablePath,
bucket_ids: List[int],
offset_spec: "OffsetSpec",
) -> Dict[int, int]:
"""List offsets for the specified buckets.
Args:
table_path: Path to the table
bucket_ids: List of bucket IDs to query
offset_spec: Offset specification (OffsetSpec.earliest(), OffsetSpec.latest(),
or OffsetSpec.timestamp(ts))
Returns:
Dict mapping bucket_id -> offset
"""
...
async def list_partition_offsets(
self,
table_path: TablePath,
partition_name: str,
bucket_ids: List[int],
offset_spec: "OffsetSpec",
) -> Dict[int, int]:
"""List offsets for buckets in a specific partition.
Args:
table_path: Path to the table
partition_name: Partition value (e.g., "US" not "region=US")
bucket_ids: List of bucket IDs to query
offset_spec: Offset specification (OffsetSpec.earliest(), OffsetSpec.latest(),
or OffsetSpec.timestamp(ts))
Returns:
Dict mapping bucket_id -> offset
"""
...
async def create_partition(
self,
table_path: TablePath,
partition_spec: Dict[str, str],
ignore_if_exists: bool = False,
) -> None:
"""Create a partition for a partitioned table.
Args:
table_path: Path to the table
partition_spec: Dict mapping partition column name to value (e.g., {"region": "US"})
ignore_if_exists: If True, don't raise error if partition already exists
"""
...
async def list_partition_infos(
self,
table_path: TablePath,
partition_spec: Optional[Dict[str, str]] = None,
) -> List["PartitionInfo"]:
"""List partitions for a partitioned table.
Args:
table_path: Path to the table
partition_spec: Optional partial partition spec to filter results.
Dict mapping partition column name to value (e.g., {"region": "US"}).
If None, returns all partitions.
Returns:
List of PartitionInfo objects
"""
...
async def get_server_nodes(self) -> List[ServerNode]:
"""Get all alive server nodes in the cluster.
Returns:
List of ServerNode objects (coordinator and tablet servers)
"""
...
def __repr__(self) -> str: ...
class DatabaseDescriptor:
"""Descriptor for a Fluss database (comment and custom properties)."""
def __init__(
self,
comment: Optional[str] = None,
custom_properties: Optional[Dict[str, str]] = None,
) -> None: ...
@property
def comment(self) -> Optional[str]: ...
def get_custom_properties(self) -> Dict[str, str]: ...
def __repr__(self) -> str: ...
class DatabaseInfo:
"""Information about a Fluss database."""
@property
def database_name(self) -> str: ...
def get_database_descriptor(self) -> DatabaseDescriptor: ...
@property
def created_time(self) -> int: ...
@property
def modified_time(self) -> int: ...
def __repr__(self) -> str: ...
class TableScan:
"""Builder for creating log scanners with flexible configuration.
Use this builder to configure projection before creating a log scanner.
Obtain a TableScan instance via `FlussTable.new_scan()`.
Example:
```python
# Record-based scanning with projection
scanner = await table.new_scan() \\
.project([0, 1, 2]) \\
.create_log_scanner()
# Batch-based scanning with column names
scanner = await table.new_scan() \\
.project_by_name(["id", "name"]) \\
.create_record_batch_log_scanner()
```
"""
def project(self, indices: List[int]) -> "TableScan":
"""Project to specific columns by their indices.
Args:
indices: List of column indices (0-based) to include in the scan.
Returns:
Self for method chaining.
"""
...
def project_by_name(self, names: List[str]) -> "TableScan":
"""Project to specific columns by their names.
Args:
names: List of column names to include in the scan.
Returns:
Self for method chaining.
"""
...
async def create_log_scanner(self) -> LogScanner:
"""Create a record-based log scanner.
Use this scanner with `poll()` to get individual records with metadata
(offset, timestamp, change_type).
Returns:
LogScanner for record-by-record scanning with `poll()`
"""
...
async def create_record_batch_log_scanner(self) -> LogScanner:
"""Create a batch-based log scanner.
Use this scanner with `poll_arrow()` to get Arrow Tables, or with
`poll_record_batch()` to get individual batches with metadata.
Returns:
LogScanner for batch-based scanning with `poll_arrow()` or `poll_record_batch()`
"""
...
def __repr__(self) -> str: ...
class FlussTable:
def new_scan(self) -> TableScan:
"""Create a new table scan builder for configuring and creating log scanners.
Use this method to create scanners with the builder pattern:
Example:
```python
# Record-based scanning
scanner = await table.new_scan() \\
.project([0, 1]) \\
.create_log_scanner()
# Batch-based scanning
scanner = await table.new_scan() \\
.project_by_name(["id", "name"]) \\
.create_record_batch_log_scanner()
```
Returns:
TableScan builder for configuring the scanner.
"""
...
def new_append(self) -> TableAppend: ...
def new_upsert(self) -> TableUpsert: ...
def new_lookup(self) -> TableLookup: ...
def get_table_info(self) -> TableInfo: ...
def get_table_path(self) -> TablePath: ...
def has_primary_key(self) -> bool: ...
def __repr__(self) -> str: ...
class TableAppend:
"""Builder for creating an AppendWriter.
Obtain via `FlussTable.new_append()`, then call `create_writer()`.
Example:
writer = table.new_append().create_writer()
"""
def create_writer(self) -> AppendWriter: ...
def __repr__(self) -> str: ...
class TableUpsert:
"""Builder for creating an UpsertWriter, with optional partial update.
Obtain via `FlussTable.new_upsert()`, then optionally call
`partial_update_by_name()` or `partial_update_by_index()`,
then call `create_writer()`.
Example:
# Full row upsert
writer = table.new_upsert().create_writer()
# Partial update by column names
writer = table.new_upsert().partial_update_by_name(["col1", "col2"]).create_writer()
# Partial update by column indices
writer = table.new_upsert().partial_update_by_index([0, 1]).create_writer()
"""
def partial_update_by_name(self, columns: List[str]) -> "TableUpsert": ...
def partial_update_by_index(self, column_indices: List[int]) -> "TableUpsert": ...
def create_writer(self) -> UpsertWriter: ...
def __repr__(self) -> str: ...
class TableLookup:
"""Builder for creating a Lookuper.
Obtain via `FlussTable.new_lookup()`, then call `create_lookuper()`.
Example:
lookuper = table.new_lookup().create_lookuper()
"""
def create_lookuper(self) -> Lookuper: ...
def __repr__(self) -> str: ...
class AppendWriter:
def append(self, row: dict | list | tuple) -> WriteResultHandle:
"""Append a single row to the table.
Args:
row: Dictionary mapping field names to values, or
list/tuple of values in schema order
Returns:
WriteResultHandle: Ignore for fire-and-forget, or await handle.wait() for acknowledgement.
Supported Types:
- Boolean, TinyInt, SmallInt, Int, BigInt (integers)
- Float, Double (floating point)
- String, Char (text)
- Bytes, Binary (binary data)
- Date, Time, Timestamp, TimestampLTZ (temporal)
- Decimal (arbitrary precision)
- Null values
Example:
writer.append({'id': 1, 'name': 'Alice', 'score': 95.5})
writer.append([1, 'Alice', 95.5])
Note:
For high-throughput bulk loading, prefer write_arrow_batch().
Use flush() to ensure all queued records are sent and acknowledged.
"""
...
def write_arrow(self, table: pa.Table) -> None: ...
def write_arrow_batch(self, batch: pa.RecordBatch) -> WriteResultHandle: ...
def write_pandas(self, df: pd.DataFrame) -> None: ...
async def flush(self) -> None: ...
def __repr__(self) -> str: ...
class UpsertWriter:
"""Writer for upserting and deleting data in a Fluss primary key table."""
def upsert(self, row: dict | list | tuple) -> WriteResultHandle:
"""Upsert a row into the table.
If a row with the same primary key exists, it will be updated.
Otherwise, a new row will be inserted.
Args:
row: Dictionary mapping field names to values, or
list/tuple of values in schema order
Returns:
WriteResultHandle: Ignore for fire-and-forget, or await handle.wait() for ack.
"""
...
def delete(self, pk: dict | list | tuple) -> WriteResultHandle:
"""Delete a row from the table by primary key.
Args:
pk: Dictionary with PK column names as keys, or
list/tuple of PK values in PK column order
Returns:
WriteResultHandle: Ignore for fire-and-forget, or await handle.wait() for ack.
"""
...
async def flush(self) -> None:
"""Flush all pending upsert/delete operations to the server."""
...
def __repr__(self) -> str: ...
class WriteResultHandle:
"""Handle for a pending write (append/upsert/delete). Ignore for fire-and-forget, or await handle.wait() for ack."""
async def wait(self) -> None:
"""Wait for server acknowledgment of this write."""
...
def __repr__(self) -> str: ...
class Lookuper:
"""Lookuper for performing primary key lookups on a Fluss table."""
async def lookup(self, pk: dict | list | tuple) -> Optional[Dict[str, object]]:
"""Lookup a row by its primary key.
Args:
pk: Dictionary with PK column names as keys, or
list/tuple of PK values in PK column order
Returns:
A dict containing the row data if found, None otherwise.
"""
...
def __repr__(self) -> str: ...
class LogScanner:
"""Scanner for reading log data from a Fluss table.
This scanner supports two modes:
- Record-based scanning via `poll()` - returns individual records with metadata
- Batch-based scanning via `poll_arrow()` / `poll_record_batch()` - returns Arrow batches
Create scanners using the builder pattern:
# Record-based scanning
scanner = await table.new_scan().create_log_scanner()
# Batch-based scanning
scanner = await table.new_scan().create_record_batch_log_scanner()
# With projection
scanner = await table.new_scan().project([0, 1]).create_log_scanner()
"""
def subscribe(self, bucket_id: int, start_offset: int) -> None:
"""Subscribe to a single bucket at a specific offset (non-partitioned tables).
Args:
bucket_id: The bucket ID to subscribe to
start_offset: The offset to start reading from (use EARLIEST_OFFSET for beginning)
"""
...
def subscribe_buckets(self, bucket_offsets: Dict[int, int]) -> None:
"""Subscribe to multiple buckets at specified offsets (non-partitioned tables).
Args:
bucket_offsets: Dict mapping bucket_id -> start_offset
"""
...
def subscribe_partition(
self, partition_id: int, bucket_id: int, start_offset: int
) -> None:
"""Subscribe to a bucket within a specific partition (partitioned tables only).
Args:
partition_id: The partition ID (from PartitionInfo.partition_id)
bucket_id: The bucket ID within the partition
start_offset: The offset to start reading from (use EARLIEST_OFFSET for beginning)
"""
...
def subscribe_partition_buckets(
self, partition_bucket_offsets: Dict[Tuple[int, int], int]
) -> None:
"""Subscribe to multiple partition+bucket combinations at once (partitioned tables only).
Args:
partition_bucket_offsets: Dict mapping (partition_id, bucket_id) tuples to start_offsets.
Example: {(partition_id_1, 0): EARLIEST_OFFSET, (partition_id_2, 1): 100}
"""
...
def unsubscribe(self, bucket_id: int) -> None:
"""Unsubscribe from a specific bucket (non-partitioned tables only).
Args:
bucket_id: The bucket ID to unsubscribe from
"""
...
def unsubscribe_partition(self, partition_id: int, bucket_id: int) -> None:
"""Unsubscribe from a specific partition bucket (partitioned tables only).
Args:
partition_id: The partition ID to unsubscribe from
bucket_id: The bucket ID within the partition
"""
...
def poll(self, timeout_ms: int) -> ScanRecords:
"""Poll for individual records with metadata.
Requires a record-based scanner (created with new_scan().create_log_scanner()).
Args:
timeout_ms: Timeout in milliseconds to wait for records.
Returns:
ScanRecords grouped by bucket. Supports flat iteration
(``for rec in records``) and per-bucket access
(``records.buckets()``, ``records.records(bucket)``).
Note:
Returns an empty ScanRecords if no records are available or timeout expires.
"""
...
def poll_record_batch(self, timeout_ms: int) -> List[RecordBatch]:
"""Poll for batches with metadata.
Requires a batch-based scanner (created with new_scan().create_record_batch_log_scanner()).
Args:
timeout_ms: Timeout in milliseconds to wait for batches.
Returns:
List of RecordBatch objects, each containing the Arrow batch along with
bucket, base_offset, and last_offset metadata.
Note:
Returns an empty list if no batches are available or timeout expires.
"""
...
def poll_arrow(self, timeout_ms: int) -> pa.Table:
"""Poll for records as an Arrow Table.
Requires a batch-based scanner (created with new_scan().create_record_batch_log_scanner()).
Args:
timeout_ms: Timeout in milliseconds to wait for records.
Returns:
PyArrow Table containing the polled records (batches merged).
Note:
Returns an empty table (with correct schema) if no records are available
or timeout expires.
"""
...
def to_pandas(self) -> pd.DataFrame:
"""Convert all data to Pandas DataFrame.
Requires a batch-based scanner (created with new_scan().create_record_batch_log_scanner()).
Reads from currently subscribed buckets until reaching their latest offsets.
You must call subscribe(), subscribe_buckets(), or subscribe_partition() first.
"""
...
def to_arrow(self) -> pa.Table:
"""Convert all data to Arrow Table.
Requires a batch-based scanner (created with new_scan().create_record_batch_log_scanner()).
Reads from currently subscribed buckets until reaching their latest offsets.
You must call subscribe(), subscribe_buckets(), or subscribe_partition() first.
"""
...
def __repr__(self) -> str: ...
class Schema:
def __init__(
self, schema: pa.Schema, primary_keys: Optional[List[str]] = None
) -> None: ...
def get_column_names(self) -> List[str]: ...
def get_column_types(self) -> List[str]: ...
def get_columns(self) -> List[Tuple[str, str]]: ...
def get_primary_keys(self) -> List[str]: ...
def __str__(self) -> str: ...
class TableDescriptor:
def __init__(
self,
schema: Schema,
*,
partition_keys: Optional[List[str]] = None,
bucket_count: Optional[int] = None,
bucket_keys: Optional[List[str]] = None,
comment: Optional[str] = None,
log_format: Optional[str] = None,
kv_format: Optional[str] = None,
properties: Optional[Dict[str, str]] = None,
custom_properties: Optional[Dict[str, str]] = None,
) -> None: ...
def get_schema(self) -> Schema: ...
class TablePath:
def __init__(self, database: str, table: str) -> None: ...
@property
def database_name(self) -> str: ...
@property
def table_name(self) -> str: ...
def table_path_str(self) -> str: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
def __hash__(self) -> int: ...
def __eq__(self, other: object) -> bool: ...
class TableInfo:
@property
def table_id(self) -> int: ...
@property
def schema_id(self) -> int: ...
@property
def created_time(self) -> int: ...
@property
def modified_time(self) -> int: ...
@property
def table_path(self) -> TablePath: ...
@property
def num_buckets(self) -> int: ...
@property
def comment(self) -> Optional[str]: ...
def get_primary_keys(self) -> List[str]: ...
def get_bucket_keys(self) -> List[str]: ...
def get_partition_keys(self) -> List[str]: ...
def has_primary_key(self) -> bool: ...
def is_partitioned(self) -> bool: ...
def get_properties(self) -> Dict[str, str]: ...
def get_custom_properties(self) -> Dict[str, str]: ...
def get_schema(self) -> Schema: ...
def get_column_names(self) -> List[str]: ...
def get_column_count(self) -> int: ...
class FlussError(Exception):
message: str
error_code: int
def __init__(self, message: str, error_code: int = -2) -> None: ...
def __str__(self) -> str: ...
@property
def is_retriable(self) -> bool: ...
class LakeSnapshot:
def __init__(self, snapshot_id: int) -> None: ...
@property
def snapshot_id(self) -> int: ...
@property
def table_buckets_offset(self) -> Dict[TableBucket, int]: ...
def get_bucket_offset(self, bucket: TableBucket) -> Optional[int]: ...
def get_table_buckets(self) -> List[TableBucket]: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
class TableBucket:
def __init__(self, table_id: int, bucket: int) -> None: ...
@staticmethod
def with_partition(
table_id: int, partition_id: int, bucket: int
) -> TableBucket: ...
@property
def table_id(self) -> int: ...
@property
def bucket_id(self) -> int: ...
@property
def partition_id(self) -> Optional[int]: ...
def __hash__(self) -> int: ...
def __eq__(self, other: object) -> bool: ...
def __str__(self) -> str: ...
def __repr__(self) -> str: ...
class PartitionInfo:
"""Information about a partition."""
@property
def partition_id(self) -> int:
"""Get the partition ID (globally unique in the cluster)."""
...
@property
def partition_name(self) -> str:
"""Get the partition name."""
...
def __repr__(self) -> str: ...
class ErrorCode:
"""Named constants for Fluss API error codes.
Server API errors have error_code > 0 or == -1.
Client-side errors have error_code == CLIENT_ERROR (-2).
These constants are convenience names — new server error codes work
automatically since error_code is a raw int, not a closed enum.
"""
CLIENT_ERROR: int
NONE: int
UNKNOWN_SERVER_ERROR: int
NETWORK_EXCEPTION: int
UNSUPPORTED_VERSION: int
CORRUPT_MESSAGE: int
DATABASE_NOT_EXIST: int
DATABASE_NOT_EMPTY: int
DATABASE_ALREADY_EXIST: int
TABLE_NOT_EXIST: int
TABLE_ALREADY_EXIST: int
SCHEMA_NOT_EXIST: int
LOG_STORAGE_EXCEPTION: int
KV_STORAGE_EXCEPTION: int
NOT_LEADER_OR_FOLLOWER: int
RECORD_TOO_LARGE_EXCEPTION: int
CORRUPT_RECORD_EXCEPTION: int
INVALID_TABLE_EXCEPTION: int
INVALID_DATABASE_EXCEPTION: int
INVALID_REPLICATION_FACTOR: int
INVALID_REQUIRED_ACKS: int
LOG_OFFSET_OUT_OF_RANGE_EXCEPTION: int
NON_PRIMARY_KEY_TABLE_EXCEPTION: int
UNKNOWN_TABLE_OR_BUCKET_EXCEPTION: int
INVALID_UPDATE_VERSION_EXCEPTION: int
INVALID_COORDINATOR_EXCEPTION: int
FENCED_LEADER_EPOCH_EXCEPTION: int
REQUEST_TIME_OUT: int
STORAGE_EXCEPTION: int
OPERATION_NOT_ATTEMPTED_EXCEPTION: int
NOT_ENOUGH_REPLICAS_AFTER_APPEND_EXCEPTION: int
NOT_ENOUGH_REPLICAS_EXCEPTION: int
SECURITY_TOKEN_EXCEPTION: int
OUT_OF_ORDER_SEQUENCE_EXCEPTION: int
DUPLICATE_SEQUENCE_EXCEPTION: int
UNKNOWN_WRITER_ID_EXCEPTION: int
INVALID_COLUMN_PROJECTION: int
INVALID_TARGET_COLUMN: int
PARTITION_NOT_EXISTS: int
TABLE_NOT_PARTITIONED_EXCEPTION: int
INVALID_TIMESTAMP_EXCEPTION: int
INVALID_CONFIG_EXCEPTION: int
LAKE_STORAGE_NOT_CONFIGURED_EXCEPTION: int
KV_SNAPSHOT_NOT_EXIST: int
PARTITION_ALREADY_EXISTS: int
PARTITION_SPEC_INVALID_EXCEPTION: int
LEADER_NOT_AVAILABLE_EXCEPTION: int
PARTITION_MAX_NUM_EXCEPTION: int
AUTHENTICATE_EXCEPTION: int
SECURITY_DISABLED_EXCEPTION: int
AUTHORIZATION_EXCEPTION: int
BUCKET_MAX_NUM_EXCEPTION: int
FENCED_TIERING_EPOCH_EXCEPTION: int
RETRIABLE_AUTHENTICATE_EXCEPTION: int
INVALID_SERVER_RACK_INFO_EXCEPTION: int
LAKE_SNAPSHOT_NOT_EXIST: int
LAKE_TABLE_ALREADY_EXIST: int
INELIGIBLE_REPLICA_EXCEPTION: int
INVALID_ALTER_TABLE_EXCEPTION: int
DELETION_DISABLED_EXCEPTION: int
class OffsetSpec:
"""Offset specification for list_offsets(), matching Java's OffsetSpec.
Use factory methods to create instances:
OffsetSpec.earliest()
OffsetSpec.latest()
OffsetSpec.timestamp(ts)
"""
@staticmethod
def earliest() -> "OffsetSpec":
"""Create an OffsetSpec for the earliest available offset."""
...
@staticmethod
def latest() -> "OffsetSpec":
"""Create an OffsetSpec for the latest available offset."""
...
@staticmethod
def timestamp(ts: int) -> "OffsetSpec":
"""Create an OffsetSpec for the offset at or after the given timestamp."""
...
def __repr__(self) -> str: ...
# Constant for earliest offset (-2)
EARLIEST_OFFSET: int
__version__: str