Copilot commented on code in PR #3846:
URL: https://github.com/apache/iceberg-python/pull/3846#discussion_r3849302052


##########
tests/catalog/test_sql.py:
##########
@@ -388,6 +389,31 @@ def test_rename_table_ignores_view_rows(warehouse: Path) 
-> None:
     assert row[0] == "VIEW"
 
 
+def test_commit_table_ignores_view_rows(warehouse: Path) -> None:
+    catalog = SqlCatalog(
+        name="test", 
uri=f"sqlite:///{warehouse.as_posix()}/test_commit_view.db", 
warehouse=f"file://{warehouse}"
+    )
+    catalog.create_namespace("ns")
+    schema = Schema(NestedField(1, "id", StringType(), required=True))
+    tbl = catalog.create_table(("ns", "a_view"), schema=schema)
+
+    # Tamper the table row into a VIEW (simulating external writer)
+    with catalog.engine.connect() as conn:
+        conn.execute(text("UPDATE iceberg_tables SET iceberg_type = 'VIEW' 
WHERE table_name = 'a_view'"))
+        conn.commit()

Review Comment:
   The direct SQL UPDATE filters only on table_name, which could accidentally 
modify multiple rows if the test DB ever contains the same table_name in other 
namespaces or catalogs. Filter by catalog_name and table_namespace as well (and 
use bind params for consistency).
   
   This issue also appears on line 411 of the same file.



-- 
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]

Reply via email to