Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pyiceberg/catalog/dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,9 @@ def _convert_dynamo_item_to_regular_dict(dynamo_json: Dict[str, Any]) -> Dict[st
raise ValueError("Only S and N data types are supported.")

values = list(val_dict.values())
assert len(values) == 1
if len(values) != 1:
raise ValueError(f"Expecting only 1 value: {values}")

column_value = values[0]
regular_json[column_name] = column_value

Expand Down
15 changes: 11 additions & 4 deletions pyiceberg/catalog/glue.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@ def _construct_table_input(
def _construct_rename_table_input(to_table_name: str, glue_table: TableTypeDef) -> TableInputTypeDef:
rename_table_input: TableInputTypeDef = {"Name": to_table_name}
# use the same Glue info to create the new table, pointing to the old metadata
assert glue_table["TableType"]
if not glue_table["TableType"]:
raise ValueError("Glue table type is missing, cannot rename table")

rename_table_input["TableType"] = glue_table["TableType"]
if "Owner" in glue_table:
rename_table_input["Owner"] = glue_table["Owner"]
Expand Down Expand Up @@ -347,9 +349,14 @@ def __init__(self, name: str, client: Optional[GlueClient] = None, **properties:
def _convert_glue_to_iceberg(self, glue_table: TableTypeDef) -> Table:
properties: Properties = glue_table["Parameters"]

assert glue_table["DatabaseName"]
assert glue_table["Parameters"]
database_name = glue_table["DatabaseName"]
database_name = glue_table.get("DatabaseName", None)
if database_name is None:
raise ValueError("Glue table is missing DatabaseName property")

parameters = glue_table.get("Parameters", None)
if parameters is None:
raise ValueError("Glue table is missing Parameters property")

table_name = glue_table["Name"]

if TABLE_TYPE not in properties:
Expand Down
2 changes: 0 additions & 2 deletions pyiceberg/cli/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ def get_namespace(ctx: Context, identifier: str, property_name: str) -> None:
identifier_tuple = Catalog.identifier_to_tuple(identifier)

namespace_properties = catalog.load_namespace_properties(identifier_tuple)
assert namespace_properties

if property_name:
if property_value := namespace_properties.get(property_name):
Expand All @@ -322,7 +321,6 @@ def get_table(ctx: Context, identifier: str, property_name: str) -> None:
identifier_tuple = Catalog.identifier_to_tuple(identifier)

metadata = catalog.load_table(identifier_tuple).metadata
assert metadata

if property_name:
if property_value := metadata.properties.get(property_name):
Expand Down
4 changes: 2 additions & 2 deletions pyiceberg/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -1362,8 +1362,8 @@ def make_compatible_name(name: str) -> str:


def _valid_avro_name(name: str) -> bool:
length = len(name)
assert length > 0, ValueError("Can not validate empty avro name")
if not len(name):
raise ValueError("Can not validate empty avro name")
first = name[0]
if not (first.isalpha() or first == "_"):
return False
Expand Down
3 changes: 2 additions & 1 deletion pyiceberg/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ def get_catalog_config(self, catalog_name: str) -> Optional[RecursiveDict]:
raise ValueError(f"Catalog configurations needs to be an object: {catalog_name}")
if catalog_name_lower in catalogs:
catalog_conf = catalogs[catalog_name_lower]
assert isinstance(catalog_conf, dict), f"Configuration path catalogs.{catalog_name_lower} needs to be an object"
if not isinstance(catalog_conf, dict):
raise ValueError(f"Configuration path catalogs.{catalog_name_lower} needs to be an object")
return catalog_conf
return None

Expand Down