@@ -1503,7 +1503,7 @@ def export_to_metastore(self):
1503
1503
self .write_table (table_name = "SKEWED_STRING_LIST_VALUES" , df = self .ms_skewed_string_list_values )
1504
1504
self .write_table (table_name = "SKEWED_COL_VALUE_LOC_MAP" , df = self .ms_skewed_col_value_loc_map )
1505
1505
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 )
1507
1507
self .write_table (table_name = "TABLE_PARAMS" , df = self .ms_table_params )
1508
1508
self .write_table (table_name = "PARTITION_KEYS" , df = self .ms_partition_keys )
1509
1509
self .write_table (table_name = "PARTITIONS" , df = self .ms_partitions )
@@ -1533,6 +1533,19 @@ def _write_dbs_table(self, table_name, df) -> None:
1533
1533
df = df .withColumn ("CTLG_NAME" , lit ("hive" ))
1534
1534
self .write_table (table_name = table_name , df = df )
1535
1535
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
+
1536
1549
1537
1550
def get_output_dir (output_dir_parent ):
1538
1551
if not output_dir_parent :
0 commit comments