You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "Fokko (via GitHub)" <gi...@apache.org> on 2023/12/12 09:11:05 UTC

[PR] Add Hive integration tests [iceberg-python]

Fokko opened a new pull request, #207:
URL: https://github.com/apache/iceberg-python/pull/207

   This makes it easier to test round trips of updating tables. Currently, we have integration tests for the REST catalog, but there the REST catalog takes care of updating the metadata.
   
   This includes a refactor of moving all the integration tests into their own module.
   
   cc @HonahX 


-- 
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add Hive integration tests [iceberg-python]

Posted by "HonahX (via GitHub)" <gi...@apache.org>.
HonahX commented on code in PR #207:
URL: https://github.com/apache/iceberg-python/pull/207#discussion_r1427569648


##########
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:
   Thanks for the context! For `test_upgrade_table_version` and `test_table_properties`, I think we might skip them in test_hive by
   ```python
   @pytest.fixture()
   def table(catalog: Catalog) -> Table:
     if catalog.name == "hive":
       pytest.skip("Not Implemented: ...")
       ...
   
   @pytest.fixture()
   def table_test_table_version(catalog: Catalog) -> Table:
       if catalog.name == "hive":
         pytest.skip("Not Implemented: ...")
        ...
   ```
   (We might also find a way to put `skip` into the decorator)
   Since the two fixtures are solely used by the two tests respectively.
   
   I think we can discuss later on whether this can work in future tests related to update table. The current PR has already done many things and it is important for `update_table` tests. This topic should not block this PR



-- 
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add Hive integration tests [iceberg-python]

Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on code in PR #207:
URL: https://github.com/apache/iceberg-python/pull/207#discussion_r1427153974


##########
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 added the lazy fixtures in https://github.com/apache/iceberg-python/pull/178 and I waited for the PR to be merged because I wanted to add them here as well. The reason I didn't do it is because `test_upgrade_table_version` and `test_table_properties` are not implemented in Hive (yet). This would mean that we need to keep them in parity which might slow down development. 



-- 
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add Hive integration tests [iceberg-python]

Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on code in PR #207:
URL: https://github.com/apache/iceberg-python/pull/207#discussion_r1427150320


##########
tests/integration/__init__.py:
##########
@@ -0,0 +1,16 @@
+# 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,

Review Comment:
   I would agree with you, but it raises an error:
   
   ```
   _____________________________________________________________________________ ERROR collecting tests/integration/test_hive.py ______________________________________________________________________________
   import file mismatch:
   imported module 'test_hive' has this __file__ attribute:
     /Users/fokkodriesprong/Desktop/iceberg-python/tests/catalog/test_hive.py
   which is not the same as the test file we want to collect:
     /Users/fokkodriesprong/Desktop/iceberg-python/tests/integration/test_hive.py
   HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
   _____________________________________________________________________________ ERROR collecting tests/integration/test_rest.py ______________________________________________________________________________
   import file mismatch:
   imported module 'test_rest' has this __file__ attribute:
     /Users/fokkodriesprong/Desktop/iceberg-python/tests/catalog/test_rest.py
   which is not the same as the test file we want to collect:
     /Users/fokkodriesprong/Desktop/iceberg-python/tests/integration/test_rest.py
   HINT: remove __pycache__ / .pyc files and/or use a unique basename for your test file modules
   ```
   
   We have the `__init__.py` files in the other folders as well 🤔 



-- 
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add Hive integration tests [iceberg-python]

Posted by "HonahX (via GitHub)" <gi...@apache.org>.
HonahX commented on code in PR #207:
URL: https://github.com/apache/iceberg-python/pull/207#discussion_r1427591155


##########
tests/integration/__init__.py:
##########
@@ -0,0 +1,16 @@
+# 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,

Review Comment:
   I raised this because we removed all `__init__.py` in tests a year ago: https://github.com/apache/iceberg/pull/5919
   I think we can rename these two files to avoid name collisions with those in `catalogs/`. This would enable us to safely delete the `__init__.py`
   
   The other `__init__.py` in `tests/` was added in https://github.com/apache/iceberg-python/pull/45/. I removed this one and all tests still work.
   
   It would be ideal to maintain consistency by not having `__init__.py` files in test folders. However, I believe this is a minor issue and should not block this PR.



-- 
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add Hive integration tests [iceberg-python]

Posted by "HonahX (via GitHub)" <gi...@apache.org>.
HonahX commented on code in PR #207:
URL: https://github.com/apache/iceberg-python/pull/207#discussion_r1427569648


##########
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:
   Thanks for the context! For `test_upgrade_table_version` and `test_table_properties`, I think we might skip them in test_hive by
   ```python
   @pytest.fixture()
   def table(catalog: Catalog) -> Table:
     if catalog.name == "hive":
       pytest.skip("Not Implemented: ...")
       ...
   
   @pytest.fixture()
   def table_test_table_version(catalog: Catalog) -> Table:
       if catalog.name == "hive":
         pytest.skip("Not Implemented: ...")
        ...
   ```
   (We might also find a way to put `skip` into the decorator)
   Since the two fixtures are solely used by the two tests respectively.
   
   I think we can discuss later on whether this can work in future tests related to update table. The current PR has already done many things and it is important to updating table tests. This topic should not block this PR



-- 
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add Hive integration tests [iceberg-python]

Posted by "HonahX (via GitHub)" <gi...@apache.org>.
HonahX commented on code in PR #207:
URL: https://github.com/apache/iceberg-python/pull/207#discussion_r1426280842


##########
tests/integration/__init__.py:
##########
@@ -0,0 +1,16 @@
+# 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,

Review Comment:
   I think we do not need `__init__.py` in test folders.



-- 
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add Hive integration tests [iceberg-python]

Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on code in PR #207:
URL: https://github.com/apache/iceberg-python/pull/207#discussion_r1427172141


##########
dev/Dockerfile:
##########
@@ -62,7 +60,7 @@ RUN chmod u+x /opt/spark/sbin/* && \
 
 RUN pip3 install -q ipython
 
-RUN pip3 install "pyiceberg[s3fs]==${PYICEBERG_VERSION}"
+RUN pip3 install "pyiceberg[s3fs,pyarrow,hive]==${PYICEBERG_VERSION}"

Review Comment:
   Thanks! I got an error before, and therefore I added it, but I've removed it again and it seems to work fine 👍 



-- 
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add Hive integration tests [iceberg-python]

Posted by "HonahX (via GitHub)" <gi...@apache.org>.
HonahX commented on code in PR #207:
URL: https://github.com/apache/iceberg-python/pull/207#discussion_r1427569648


##########
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:
   Thanks for the context! For `test_upgrade_table_version` and `test_table_properties`, I think we might skip them in test_hive by
   ```python
   @pytest.fixture()
   def table(catalog: Catalog) -> Table:
     if catalog.name == "hive":
       pytest.skip("Not Implemented: ...")
       ...
   
   @pytest.fixture()
   def table_test_table_version(catalog: Catalog) -> Table:
       if catalog.name == "hive":
         pytest.skip("Not Implemented: ...")
        ...
   ```
   (We might also find a way to put `skip` into the decorator)
   Since the two fixtures are solely used by the two tests respectively.
   
   I think this can be discussed further later. The current PR has already done many things and it is important to updating table tests



-- 
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add Hive integration tests [iceberg-python]

Posted by "HonahX (via GitHub)" <gi...@apache.org>.
HonahX commented on code in PR #207:
URL: https://github.com/apache/iceberg-python/pull/207#discussion_r1427591155


##########
tests/integration/__init__.py:
##########
@@ -0,0 +1,16 @@
+# 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,

Review Comment:
   I raised this because we previously removed all `__init__.py` in tests: https://github.com/apache/iceberg/pull/5919
   I think we can rename these two files to avoid name collisions with those in `catalogs/`. This would enable us to safely delete the `__init__.py`
   
   The other `__init__.py` in `tests/` was added in https://github.com/apache/iceberg-python/pull/45/. I removed this one and all tests still work.
   
   It would be ideal to maintain consistency by not having `__init__.py` files in test folders. However, I believe this is a minor issue and should not block this PR.



-- 
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add Hive integration tests [iceberg-python]

Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on PR #207:
URL: https://github.com/apache/iceberg-python/pull/207#issuecomment-1896052914

   Thanks @HonahX for the review 👍 


-- 
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add Hive integration tests [iceberg-python]

Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko merged PR #207:
URL: https://github.com/apache/iceberg-python/pull/207


-- 
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add Hive integration tests [iceberg-python]

Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on code in PR #207:
URL: https://github.com/apache/iceberg-python/pull/207#discussion_r1455755578


##########
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 actually like this suggestion a lot, let me add this to the PR



-- 
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add Hive integration tests [iceberg-python]

Posted by "HonahX (via GitHub)" <gi...@apache.org>.
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
   ```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?



##########
tests/integration/__init__.py:
##########
@@ -0,0 +1,16 @@
+# 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,

Review Comment:
   I think we do not need `__init__.py` in tests folder.



##########
dev/Dockerfile:
##########
@@ -62,7 +60,7 @@ RUN chmod u+x /opt/spark/sbin/* && \
 
 RUN pip3 install -q ipython
 
-RUN pip3 install "pyiceberg[s3fs]==${PYICEBERG_VERSION}"
+RUN pip3 install "pyiceberg[s3fs,pyarrow,hive]==${PYICEBERG_VERSION}"

Review Comment:
   Do we need `pyarrow` in the docker image? I think in `provision.py` we only need pyiceberg to create some empty table with UUID column. Since we use minio for storage, `s3fs` can help us write the metadata



-- 
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add Hive integration tests [iceberg-python]

Posted by "HonahX (via GitHub)" <gi...@apache.org>.
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org