codeant-ai-for-open-source[bot] commented on code in PR #41055:
URL: https://github.com/apache/superset/pull/41055#discussion_r3414495245
##########
tests/unit_tests/db_engine_specs/test_trino.py:
##########
@@ -343,6 +343,124 @@ def test_get_extra_table_metadata(mocker: MockerFixture)
-> None:
assert result["partitions"]["latest"] == {"ds": "01-01-19", "hour": 1}
+def test_get_extra_table_metadata_iceberg_unpartitioned(
+ mocker: MockerFixture,
+) -> None:
+ """
+ Iceberg ``$partitions`` metadata fields must not be treated as partition
+ columns, so an unpartitioned Iceberg table yields no partition metadata and
+ no latest-partition query.
+ """
+ from superset.db_engine_specs.trino import TrinoEngineSpec
+
+ db_mock = mocker.MagicMock()
+ db_mock.get_indexes = Mock(
+ return_value=[
+ {
+ "name": "partition",
+ "column_names": ["data", "file_count", "record_count",
"total_size"],
+ }
+ ]
+ )
+ db_mock.get_extra = Mock(return_value={})
+ db_mock.has_view = Mock(return_value=None)
+ db_mock.get_df = Mock()
+ result = TrinoEngineSpec.get_extra_table_metadata(
+ db_mock,
+ Table("test_table", "test_schema"),
+ )
+ assert "partitions" not in result
+ db_mock.get_df.assert_not_called()
+
+
+def test_get_extra_table_metadata_iceberg_partitioned(
+ mocker: MockerFixture,
+) -> None:
+ """
+ A genuinely partitioned Iceberg table exposes a ``partition`` ROW column
+ alongside the metadata fields. Since the real partition columns are nested
+ in the ROW and not directly queryable here, the partition block is skipped
+ rather than generating an invalid latest-partition query.
+ """
+ from superset.db_engine_specs.trino import TrinoEngineSpec
+
+ db_mock = mocker.MagicMock()
+ db_mock.get_indexes = Mock(
+ return_value=[
+ {
+ "name": "partition",
+ "column_names": [
+ "partition",
+ "record_count",
+ "file_count",
+ "total_size",
+ "data",
+ ],
+ }
+ ]
+ )
+ db_mock.get_extra = Mock(return_value={})
+ db_mock.has_view = Mock(return_value=None)
+ db_mock.get_df = Mock()
+ result = TrinoEngineSpec.get_extra_table_metadata(
+ db_mock,
+ Table("test_table", "test_schema"),
+ )
+ assert "partitions" not in result
+ db_mock.get_df.assert_not_called()
+
+
+def test_filter_iceberg_partition_indexes() -> None:
+ from superset.db_engine_specs.trino import TrinoEngineSpec
Review Comment:
**Suggestion:** Add an inline docstring to this newly added test function so
it complies with the requirement that new functions are documented.
[custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
This is a newly added test function in the PR and it has no docstring
immediately under the definition. The custom rule requires newly added Python
functions and classes to include docstrings, so the suggestion correctly
identifies a real violation.
</details>
[Fix in
Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=67b49aa201204f85b541560a24dce2d1&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
| [Fix in VSCode
Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=67b49aa201204f85b541560a24dce2d1&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** tests/unit_tests/db_engine_specs/test_trino.py
**Line:** 413:414
**Comment:**
*Custom Rule: Add an inline docstring to this newly added test function
so it complies with the requirement that new functions are documented.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41055&comment_hash=2cd36ead0245c95372e3c1d5869da7ba8f18a30169e032ad0856580af241dd52&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41055&comment_hash=2cd36ead0245c95372e3c1d5869da7ba8f18a30169e032ad0856580af241dd52&reaction=dislike'>👎</a>
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]