HonahX commented on code in PR #207: URL: https://github.com/apache/iceberg-python/pull/207#discussion_r1426357825
########## tests/integration/test_hive.py: ########## @@ -0,0 +1,409 @@ +# 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. +# pylint:disable=redefined-outer-name + +import math +import uuid +from typing import Dict +from urllib.parse import urlparse + +import pyarrow.parquet as pq +import pytest +from pyarrow.fs import S3FileSystem + +from pyiceberg.catalog import Catalog, load_catalog +from pyiceberg.exceptions import NoSuchTableError +from pyiceberg.expressions import ( + And, + EqualTo, + GreaterThanOrEqual, + IsNaN, + LessThan, + NotEqualTo, + NotNaN, +) +from pyiceberg.io.pyarrow import pyarrow_to_schema +from pyiceberg.schema import Schema +from pyiceberg.table import Table +from pyiceberg.types import ( + BooleanType, + IntegerType, + NestedField, + StringType, + TimestampType, +) + +DEFAULT_PROPERTIES: Dict[str, str] = {} + + +@pytest.fixture() +def catalog() -> Catalog: + return load_catalog( + "local", + **{ + "type": "hive", + "uri": "http://localhost:9083", + "s3.endpoint": "http://localhost:9000", + "s3.access-key-id": "admin", + "s3.secret-access-key": "password", + }, + ) + + +@pytest.fixture() +def table_test_null_nan(catalog: Catalog) -> Table: + return catalog.load_table("default.test_null_nan") + + +@pytest.fixture() +def table_test_null_nan_rewritten(catalog: Catalog) -> Table: + return catalog.load_table("default.test_null_nan_rewritten") + + +@pytest.fixture() +def table_test_limit(catalog: Catalog) -> Table: Review Comment: I wonder if we could use `pytest_lazy_fixture` to avoid duplicate tests in `test_rest.py` and `test_hive.py` like what we did in https://github.com/apache/iceberg-python/blob/2bd8cf21fe92edc0cca2fc9b39d676d48abfafec/tests/catalog/test_sql.py#L113-L120. Here it can be something like ```python @pytest.fixture(params=[ pytest.lazy_fixture('catalog_hive'), pytest.lazy_fixture('catalog_rest') ]) def catalog(request): return request.param @pytest.fixture() def table_test_limit(catalog: Catalog) -> Table: ``` and `table_test_limit` should load table from both catalogs in turn I modified an example from https://pypi.org/project/pytest-lazy-fixture/ ```python @pytest.fixture(params=[ pytest.lazy_fixture('one'), pytest.lazy_fixture('two') ]) def combined(request): return request.param @pytest.fixture def one(): return 1 @pytest.fixture def two(): return 2 @pytest.fixture def combined2(combined): return combined def test_func(combined2): assert combined2 in [1, 2] ``` which seems to work. I will try to test this in our integration test later. If it works, I think it can be worth to implement. What do you think? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org