Skip to content

StaticTable _metadata_location_from_version_hint metadata_location python string format ERROR #2608

@qccash

Description

@qccash

Apache Iceberg version

0.10.0 (latest release)

Please describe the bug 🐞

#1887 (comment)

If the content in version-hint.text is not endswith 'metadata.json'.
The ERROR stack should be like;

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/xxxxxx/python-env/pyiceberg/lib/python3.11/site-packages/pyiceberg/table/__init__.py", line 1599, in from_metadata
    metadata = FromInputFile.table_metadata(file)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/xxxxxx/python-env/pyiceberg/lib/python3.11/site-packages/pyiceberg/serializers.py", line 113, in table_metadata
    with input_file.open() as input_stream:
         ^^^^^^^^^^^^^^^^^
  File "/home/xxxxxx/python-env/pyiceberg/lib/python3.11/site-packages/pyiceberg/io/pyarrow.py", line 333, in open
    input_file = self._filesystem.open_input_file(self._path)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "pyarrow/_fs.pyx", line 814, in pyarrow._fs.FileSystem.open_input_file
  File "pyarrow/error.pxi", line 155, in pyarrow.lib.pyarrow_internal_check_status
  File "pyarrow/error.pxi", line 92, in pyarrow.lib.check_status
FileNotFoundError: [Errno 2] Path does not exist 'static/table/path/metadata/v%s.metadata.json'. Detail: [errno 2] No such file or directory

Here is a syntax error in StaticTable._metadata_location_from_version_hint, should be

        if content.endswith(".metadata.json"):
            return os.path.join(metadata_location, "metadata", content)
        elif content.isnumeric():
            return os.path.join(metadata_location, "metadata", "v{}.metadata.json").format(content)
        else:
            return os.path.join(metadata_location, "metadata", "{}.metadata.json").format(content)

In pytest.fixture table_location, the case metadata_filename = f"{uuid.uuid4()}.metadata.json" does not cover the faulty code path.

Willingness to contribute

  • I can contribute a fix for this bug independently
  • I would be willing to contribute a fix for this bug with guidance from the Iceberg community
  • I cannot contribute a fix for this bug at this time

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions