rdblue commented on a change in pull request #1216:
URL: https://github.com/apache/iceberg/pull/1216#discussion_r475757923
##########
File path: python/iceberg/core/base_metastore_tables.py
##########
@@ -14,46 +14,40 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+from typing import Tuple
-from iceberg.api import Tables
-from iceberg.exceptions import AlreadyExistsException, CommitFailedException,
NoSuchTableException
-
+from . import TableOperations
from .base_table import BaseTable
from .table_metadata import TableMetadata
+from ..api import PartitionSpec, Schema, Table, Tables
+from ..exceptions import AlreadyExistsException, CommitFailedException,
NoSuchTableException
class BaseMetastoreTables(Tables):
- DOT = '.'
- def __init__(self, conf):
+ def __init__(self: "BaseMetastoreTables", conf: dict) -> None:
self.conf = conf
- def new_table_ops(self, conf, database, table):
+ def new_table_ops(self: "BaseMetastoreTables", conf: dict, database: str,
table: str) -> "TableOperations":
raise RuntimeError("Abstract Implementation")
- 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]
+ def load(self: "BaseMetastoreTables", table_identifier: str) -> Table:
+ database, table = _parse_table_identifier(table_identifier)
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))
+ if ops.current():
+ return BaseTable(ops, "{}.{}".format(database, table))
+ raise NoSuchTableException("Table does not exist:
{}.{}".format(database, table))
- def create(self, schema, table_identifier=None, spec=None,
properties=None):
- database, table = table_identifier.rsplit(BaseMetastoreTables.DOT, 1)
+ def create(self: "BaseMetastoreTables", schema: Schema, table_identifier:
str, spec: PartitionSpec = None,
+ properties: dict = None) -> Table:
+ database, table = _parse_table_identifier(table_identifier)
ops = self.new_table_ops(self.conf, database, table)
- if ops.current() is not None:
+ if ops.current() is not None: # not None check here to ensure
MagicMocks aren't treated as None
Review comment:
I'm not sure I understand this comment. Will a mock object evaluate to
`False` in an if?
----------------------------------------------------------------
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]