rymurr commented on a change in pull request #1216:
URL: https://github.com/apache/iceberg/pull/1216#discussion_r475209811
##########
File path: python/iceberg/core/base_metastore_tables.py
##########
@@ -16,28 +16,51 @@
# under the License.
from iceberg.api import Tables
-from iceberg.exceptions import NoSuchTableException
+from iceberg.exceptions import AlreadyExistsException, CommitFailedException,
NoSuchTableException
from .base_table import BaseTable
+from .table_metadata import TableMetadata
class BaseMetastoreTables(Tables):
+ DOT = '.'
def __init__(self, conf):
self.conf = conf
def new_table_ops(self, conf, database, table):
raise RuntimeError("Abstract Implementation")
- def load(self, database, table):
+ def load(self, table_identifier):
+ parts = table_identifier.rsplit(BaseMetastoreTables.DOT, 1)
+ if len(parts) > 1:
+ database = parts[0]
+ table = parts[1]
+ else:
+ database = "default"
+ table = parts[0]
ops = self.new_table_ops(self.conf, database, table)
if ops.current() is None:
raise NoSuchTableException("Table does not exist:
{}.{}".format(database, table))
return BaseTable(ops, "{}.{}".format(database, table))
- def create(self, schema, spec, table_identifier=None, database=None,
table=None):
- raise RuntimeError("Not Yet Implemented")
+ def create(self, schema, table_identifier=None, spec=None,
properties=None):
+ database, table = table_identifier.rsplit(BaseMetastoreTables.DOT, 1)
+ ops = self.new_table_ops(self.conf, database, table)
+ if ops.current() is not None:
+ raise AlreadyExistsException("Table already exists: " +
table_identifier)
+
+ base_location = self.default_warehouse_location(self.conf, database,
table)
+
+ metadata = TableMetadata.new_table_metadata(ops, schema, spec,
base_location, dict() if properties is None else properties)
Review comment:
yeah, its strange it wasn't caught by flake8. Fixed now
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]