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
__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
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.