fsspec
FileIO implementation for reading and writing table files that uses fsspec compatible filesystems.
FsspecFileIO
¶
Bases: FileIO
A FileIO implementation that uses fsspec.
Source code in pyiceberg/io/fsspec.py
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 | |
__getstate__()
¶
Create a dictionary of the FsSpecFileIO fields used when pickling.
__setstate__(state)
¶
delete(location)
¶
Delete the file at the given location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
Union[str, InputFile, OutputFile]
|
The URI to the file--if an InputFile instance or an OutputFile instance is provided, the location attribute for that instance is used as the location to delete. |
required |
Source code in pyiceberg/io/fsspec.py
get_fs(scheme, hostname=None)
¶
Get a filesystem for a specific scheme, cached per thread.
Source code in pyiceberg/io/fsspec.py
new_input(location)
¶
Get an FsspecInputFile instance to read bytes from the file at the given location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
str
|
A URI or a path to a local file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
FsspecInputFile |
FsspecInputFile
|
An FsspecInputFile instance for the given location. |
Source code in pyiceberg/io/fsspec.py
new_output(location)
¶
Get an FsspecOutputFile instance to write bytes to the file at the given location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
str
|
A URI or a path to a local file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
FsspecOutputFile |
FsspecOutputFile
|
An FsspecOutputFile instance for the given location. |
Source code in pyiceberg/io/fsspec.py
FsspecInputFile
¶
Bases: InputFile
An input file implementation for the FsspecFileIO.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
str
|
A URI to a file location. |
required |
fs
|
AbstractFileSystem
|
An fsspec filesystem instance. |
required |
Source code in pyiceberg/io/fsspec.py
__len__()
¶
Return the total length of the file, in bytes.
Source code in pyiceberg/io/fsspec.py
exists()
¶
open(seekable=True)
¶
Create an input stream for reading the contents of the file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seekable
|
bool
|
If the stream should support seek, or if it is consumed sequential. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
OpenFile |
InputStream
|
An fsspec compliant file-like object. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the file does not exist. |
Source code in pyiceberg/io/fsspec.py
FsspecOutputFile
¶
Bases: OutputFile
An output file implementation for the FsspecFileIO.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
str
|
A URI to a file location. |
required |
fs
|
AbstractFileSystem
|
An fsspec filesystem instance. |
required |
Source code in pyiceberg/io/fsspec.py
__len__()
¶
Return the total length of the file, in bytes.
Source code in pyiceberg/io/fsspec.py
create(overwrite=False)
¶
Create an output stream for reading the contents of the file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
overwrite
|
bool
|
Whether to overwrite the file if it already exists. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
OpenFile |
OutputStream
|
An fsspec compliant file-like object. |
Raises:
| Type | Description |
|---|---|
FileExistsError
|
If the file already exists at the location and overwrite is set to False. |
Note
If overwrite is set to False, a check is first performed to verify that the file does not exist. This is not thread-safe and a possibility does exist that the file can be created by a concurrent process after the existence check yet before the output stream is created. In such a case, the default behavior will truncate the contents of the existing file when opening the output stream.
Source code in pyiceberg/io/fsspec.py
exists()
¶
to_input_file()
¶
Return a new FsspecInputFile for the location at self.location.
S3RequestSigner
¶
Bases: ABC
Abstract base class for S3 request signers.
Source code in pyiceberg/io/fsspec.py
S3V4RestSigner
¶
Bases: S3RequestSigner
An S3 request signer that uses an external REST signing service to sign requests.