You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/01/20 16:17:02 UTC
[GitHub] [iceberg] cccs-eric opened a new issue #3939: [Python legacy] partition_spec returning class instead of proper Type
cccs-eric opened a new issue #3939:
URL: https://github.com/apache/iceberg/issues/3939
When reading a manifest using python_legacy and listing its entries, we [project the schema ](https://github.com/apache/iceberg/blob/b6ce66112bea752513d5317c0813c77ea980643a/python_legacy/iceberg/core/manifest_reader.py#L143)using `partition_type()`. When building the `partition_type` struct, we [return the class type instead of the instance type](https://github.com/apache/iceberg/blob/b6ce66112bea752513d5317c0813c77ea980643a/python_legacy/iceberg/api/partition_spec.py#L79). Look at this debugger screenshot:

`partition` is a struct composed of only 1 field: `domainName_trunc` and its type is `<class iceberg.aspi.types.types.StringType` while the other fields' type show up as `string`, `long`, etc...
If you try to use the `IndexByName` visitor ([as done by Schema.__init()__](https://github.com/apache/iceberg/blob/b6ce66112bea752513d5317c0813c77ea980643a/python_legacy/iceberg/api/schema.py#L48)), you will end up with the following error:
```
Exception has occurred: RuntimeError (note: full exception trace is shown but execution is paused at: _run_module_as_main)
Invalid type for arg: <class 'iceberg.api.types.types.StringType'>
File "/home/git/opensource/iceberg/python_legacy/iceberg/api/types/type_util.py", line 150, in visit
raise RuntimeError("Invalid type for arg: %s" % arg)
File "/home/git/opensource/iceberg/python_legacy/iceberg/api/types/type_util.py", line 124, in visit
result = visit(field.type, visitor)
File "/home/git/opensource/iceberg/python_legacy/iceberg/api/types/type_util.py", line 124, in visit
result = visit(field.type, visitor)
File "/home/git/opensource/iceberg/python_legacy/iceberg/api/types/type_util.py", line 91, in index_by_name
return visit(struct, IndexByName())
File "/home/git/opensource/iceberg/python_legacy/iceberg/api/schema.py", line 48, in __init__
self._name_to_id = type_util.index_by_name(self.struct)
File "/home/git/opensource/iceberg/python_legacy/iceberg/core/manifest_entry.py", line 122, in project_schema
return ManifestEntry.wrap_file_schema(Schema(DataFile.get_type(part_type).fields)
File "/home/git/opensource/iceberg/python_legacy/iceberg/core/manifest_reader.py", line 143, in entries
proj_schema = ManifestEntry.project_schema(self.spec.partition_type(), columns)
File "/home/git/opensource/iceberg/python_legacy/test_azure.py", line 71, in <module>
```
The fix for this is simple and I'll provide a 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