Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import pyarrow as pa
from itertools import islice
from loguru import logger
from pyiceberg.catalog import Catalog
from pyiceberg.schema import Schema
from pyiceberg.table import Table, FileScanTask
Expand Down Expand Up @@ -211,9 +212,9 @@ def _seek_to_usable_file(self) -> Iterator[FileScanTask]:
self.num_of_skipped_records += record_count
continue
yield task
except Exception:
print("Could not read iceberg table:\n")
raise Exception
except Exception as err:
logger.exception(err)
raise
Comment thread
mengw15 marked this conversation as resolved.
else:
return iter([])

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 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.

from unittest.mock import Mock, patch

import pytest

from core.storage.iceberg import iceberg_document
from core.storage.iceberg.iceberg_document import IcebergIterator


def test_seek_to_usable_file_preserves_original_error():
failing_table = Mock()
failing_table.refresh.side_effect = RuntimeError(
"Catalog auth failure: token expired"
)

with patch.object(
iceberg_document, "load_table_metadata", return_value=failing_table
):
it = IcebergIterator(0, None, None, "ns", "tbl", None, None)
with pytest.raises(RuntimeError, match="Catalog auth failure"):
next(it)
Loading