@@ -1503,7 +1503,7 @@ def export_to_metastore(self):
15031503 self .write_table (table_name = "SKEWED_STRING_LIST_VALUES" , df = self .ms_skewed_string_list_values )
15041504 self .write_table (table_name = "SKEWED_COL_VALUE_LOC_MAP" , df = self .ms_skewed_col_value_loc_map )
15051505 self .write_table (table_name = "SORT_COLS" , df = self .ms_sort_cols )
1506- self .write_table (table_name = "TBLS" , df = self .ms_tbls )
1506+ self ._write_tbls_table (table_name = "TBLS" , df = self .ms_tbls )
15071507 self .write_table (table_name = "TABLE_PARAMS" , df = self .ms_table_params )
15081508 self .write_table (table_name = "PARTITION_KEYS" , df = self .ms_partition_keys )
15091509 self .write_table (table_name = "PARTITIONS" , df = self .ms_partitions )
@@ -1533,6 +1533,19 @@ def _write_dbs_table(self, table_name, df) -> None:
15331533 df = df .withColumn ("CTLG_NAME" , lit ("hive" ))
15341534 self .write_table (table_name = table_name , df = df )
15351535
1536+ def _write_tbls_table (self , table_name , df ) -> None :
1537+ """
1538+ Handling IS_REWRITE_ENABLED column in TBLS table which does not accept null.
1539+ Context:
1540+ - HIVE-14496 added `IS_REWRITE_ENABLED` column to Hive 2.2.0, and it doesn't accept null until HIVE-18046 (Hive 3.0.0)
1541+ """
1542+
1543+ source_df = self .read_table (table_name = table_name )
1544+ for col in [i .jsonValue () for i in source_df .schema ]:
1545+ if col ["name" ] == "IS_REWRITE_ENABLED" :
1546+ df = df .withColumn ("IS_REWRITE_ENABLED" , lit (0 ))
1547+ self .write_table (table_name = table_name , df = df )
1548+
15361549
15371550def get_output_dir (output_dir_parent ):
15381551 if not output_dir_parent :
0 commit comments