-
Notifications
You must be signed in to change notification settings - Fork 406
Closed as not planned
Labels
Description
Apache Iceberg version
None
Please describe the bug 🐞
I'm not able to create a table in Hive Metastore using the example code from https://py.iceberg.apache.org/api/#create-a-table.
When I run
from pyiceberg.schema import Schema
from pyiceberg.types import (
TimestampType,
FloatType,
DoubleType,
StringType,
NestedField,
StructType,
)
schema = Schema(
NestedField(field_id=1, name="datetime", field_type=TimestampType(), required=True),
NestedField(field_id=2, name="symbol", field_type=StringType(), required=True),
NestedField(field_id=3, name="bid", field_type=FloatType(), required=False),
NestedField(field_id=4, name="ask", field_type=DoubleType(), required=False),
NestedField(
field_id=5,
name="details",
field_type=StructType(
NestedField(
field_id=4, name="created_by", field_type=StringType(), required=False
),
),
required=False,
),
)
from pyiceberg.partitioning import PartitionSpec, PartitionField
from pyiceberg.transforms import DayTransform
partition_spec = PartitionSpec(
PartitionField(
source_id=1, field_id=1000, transform=DayTransform(), name="datetime_day"
)
)
from pyiceberg.table.sorting import SortOrder, SortField
from pyiceberg.transforms import IdentityTransform
# Sort on the symbol
sort_order = SortOrder(SortField(source_id=2, transform=IdentityTransform()))
# --- Additions ---
from pyiceberg.catalog import load_hive
catalog = load_hive('my_catalog', {'uri': 'thrift://myhost:9080'})
catalog.create_table(
identifier='mynamespace.mytable',
schema=schema,
partition_spec=partition_spec,
sort_order=sort_order
)I get
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/me/.local/lib/python3.10/site-packages/pyiceberg/catalog/hive.py", line 414, in create_table
self._create_hive_table(open_client, tbl)
File "/home/me/.local/lib/python3.10/site-packages/pyiceberg/catalog/hive.py", line 363, in _create_hive_table
open_client.create_table(hive_table)
File "/home/me/.local/lib/python3.10/site-packages/hive_metastore/ThriftHiveMetastore.py", line 3431, in create_table
self.recv_create_table()
File "/home/me/.local/lib/python3.10/site-packages/hive_metastore/ThriftHiveMetastore.py", line 3455, in recv_create_table
raise result.o2
hive_metastore.ttypes.InvalidObjectException: InvalidObjectException(message="Id shouldn't be set but table mynamespace.mytablehas the Id set to -1. It's a read-only option")
I get the same error when I try to register a table using the register_table procedure.
I'm able to reproduce this with clean installation of pyiceberg 0.9.1 and several of the earlier versions.
Willingness to contribute
- I can contribute a fix for this bug independently
- I would be willing to contribute a fix for this bug with guidance from the Iceberg community
- I cannot contribute a fix for this bug at this time