@@ -47,11 +47,15 @@ def convert_avro_to_sql(avro_schema_path, dbscript_file_path, db_dialect, emit_c
47
47
if isinstance (schema , list ):
48
48
tables_sql = []
49
49
for schema in schema_list :
50
+ if not isinstance (schema , dict ) or "type" not in schema or schema ["type" ] != "record" :
51
+ continue
50
52
tables_sql .extend (generate_sql (
51
53
schema , db_dialect , emit_cloudevents_columns , schema_list , schema_name ))
52
54
with open (dbscript_file_path , "w" , encoding = "utf-8" ) as sql_file :
53
55
sql_file .write ("\n " .join (tables_sql ))
54
56
else :
57
+ if not isinstance (schema , dict ) or "type" not in schema or schema ["type" ] != "record" :
58
+ raise ValueError ("Invalid Avro record schema" )
55
59
tables_sql = generate_sql (
56
60
schema , db_dialect , emit_cloudevents_columns , schema_list , schema_name )
57
61
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
662
666
663
667
if isinstance (schema , list ):
664
668
for schema in schema_list :
669
+ if not isinstance (schema , dict ) or "type" not in schema or schema ["type" ] != "record" :
670
+ continue
665
671
model = generate_nosql (schema , nosql_dialect ,
666
672
emit_cloudevents_columns , schema_list )
667
673
file_name = os .path .join (
@@ -672,6 +678,8 @@ def convert_avro_to_nosql(avro_schema_path, nosql_file_path, nosql_dialect, emit
672
678
else :
673
679
nosql_file .write (model )
674
680
else :
681
+ if not isinstance (schema , dict ) or "type" not in schema or schema ["type" ] != "record" :
682
+ raise ValueError ("Invalid Avro record schema" )
675
683
model = generate_nosql (schema , nosql_dialect ,
676
684
emit_cloudevents_columns , schema_list )
677
685
file_name = os .path .join (
0 commit comments