kevinjqliu commented on code in PR #1498:
URL: https://github.com/apache/iceberg-python/pull/1498#discussion_r1912524672


##########
tests/integration/test_add_files.py:
##########
@@ -616,13 +616,18 @@ def 
test_add_files_with_timestamp_tz_ns_fails(session_catalog: Catalog, format_v
 
     # add the parquet files as data files
     with pytest.raises(
-        TypeError,
-        match=re.escape(
-            "Iceberg does not yet support 'ns' timestamp precision. Use 
'downcast-ns-timestamp-to-us-on-write' configuration property to automatically 
downcast 'ns' to 'us' on write."
-        ),
-    ):
+        UnsupportedPyArrowTypeException,
+        match=re.escape("Column 'quux' has an unsupported type: timestamp[ns, 
tz=UTC]"),
+    ) as exc_info:
         tbl.add_files(file_paths=[file_path])
 
+    exception_cause = exc_info.value.__cause__
+    assert isinstance(exception_cause, TypeError)
+    assert (
+        "Iceberg does not yet support 'ns' timestamp precision. Use 
'downcast-ns-timestamp-to-us-on-write' configuration property to automatically 
downcast 'ns' to 'us' on write."

Review Comment:
   I think for this error, we actually want to propagate it upwards. We want to 
let the users know there is the `downcast-ns-timestamp-to-us-on-write` 
configuration.
   
   Maybe we can try reraising the underlying error to preserve its message
   ```
       try:
           result = visit_pyarrow(field_type, visitor)
       except TypeError as e:
           # Raise a custom exception while preserving the original error 
message and traceback
           raise UnsupportedPyArrowTypeException(
               obj, 
               f"Column '{obj.name}' has an unsupported type: {field_type}"
           ) from e
   ```



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

Reply via email to