Skip to content

Commit 88eed6e

Browse files
author
Clemens Vasters
committed
skip enums when processing a union
1 parent f568bd3 commit 88eed6e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

avrotize/avrotodb.py

+8
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,15 @@ def convert_avro_to_sql(avro_schema_path, dbscript_file_path, db_dialect, emit_c
4747
if isinstance(schema, list):
4848
tables_sql = []
4949
for schema in schema_list:
50+
if not isinstance(schema, dict) or "type" not in schema or schema["type"] != "record":
51+
continue
5052
tables_sql.extend(generate_sql(
5153
schema, db_dialect, emit_cloudevents_columns, schema_list, schema_name))
5254
with open(dbscript_file_path, "w", encoding="utf-8") as sql_file:
5355
sql_file.write("\n".join(tables_sql))
5456
else:
57+
if not isinstance(schema, dict) or "type" not in schema or schema["type"] != "record":
58+
raise ValueError("Invalid Avro record schema")
5559
tables_sql = generate_sql(
5660
schema, db_dialect, emit_cloudevents_columns, schema_list, schema_name)
5761
with open(dbscript_file_path, "w", encoding="utf-8") as sql_file:
@@ -662,6 +666,8 @@ def convert_avro_to_nosql(avro_schema_path, nosql_file_path, nosql_dialect, emit
662666

663667
if isinstance(schema, list):
664668
for schema in schema_list:
669+
if not isinstance(schema, dict) or "type" not in schema or schema["type"] != "record":
670+
continue
665671
model = generate_nosql(schema, nosql_dialect,
666672
emit_cloudevents_columns, schema_list)
667673
file_name = os.path.join(
@@ -672,6 +678,8 @@ def convert_avro_to_nosql(avro_schema_path, nosql_file_path, nosql_dialect, emit
672678
else:
673679
nosql_file.write(model)
674680
else:
681+
if not isinstance(schema, dict) or "type" not in schema or schema["type"] != "record":
682+
raise ValueError("Invalid Avro record schema")
675683
model = generate_nosql(schema, nosql_dialect,
676684
emit_cloudevents_columns, schema_list)
677685
file_name = os.path.join(

avrotize/avrotokusto.py

+2
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ def convert_avro_to_kusto_script(self, avro_schema_path, avro_record_type, emit_
245245

246246
type_dict = build_flat_type_dict(schema)
247247
for record in schema:
248+
if not isinstance(record, dict) or "type" not in record or record["type"] != "record":
249+
continue
248250
kusto_script.extend(self.convert_record_to_kusto(type_dict,
249251
record, emit_cloudevents_columns, emit_cloudevents_dispatch_table))
250252
return "\n".join(kusto_script)

0 commit comments

Comments
 (0)