Utility class to generate TBLPROPERTIES corresponding to various iceberg catalogs.
| 110 | |
| 111 | |
| 112 | class IcebergCatalogs: |
| 113 | """Utility class to generate TBLPROPERTIES corresponding to various iceberg catalogs.""" |
| 114 | |
| 115 | def __init__(self, database): |
| 116 | """Create a IcebergCatalogs object parameterized by database name.""" |
| 117 | self.database = database |
| 118 | |
| 119 | hive_catalog = "'iceberg.catalog'='hive.catalog'" |
| 120 | hive_catalogs = "'iceberg.catalog'='ice_hive_cat'" |
| 121 | hadoop_tables = "'iceberg.catalog'='hadoop.tables'" |
| 122 | hadoop_catalogs = "'iceberg.catalog'='ice_hadoop_cat'" |
| 123 | |
| 124 | def get_iceberg_catalog_properties(self): |
| 125 | """Return a list containing TBLPROPERTIES corresponding to various iceberg catalogs. |
| 126 | The TBLPROPERTIES can be used to create tables.""" |
| 127 | ice_cat_location = "/test-warehouse/{0}/hadoop_catalog_test/".format(self.database) |
| 128 | ice_cat_location_fs = get_fs_path(ice_cat_location) |
| 129 | hadoop_catalog = ("'iceberg.catalog'='hadoop.catalog', " |
| 130 | + "'iceberg.catalog_location'='{0}'".format(ice_cat_location_fs)) |
| 131 | return [ |
| 132 | self.hadoop_tables, |
| 133 | self.hive_catalog, |
| 134 | self.hive_catalogs, |
| 135 | self.hadoop_catalogs, |
| 136 | hadoop_catalog |
| 137 | ] |
| 138 | |
| 139 | def is_a_hive_catalog(self, catalog): |
| 140 | """Return true if the catalog property is for a Hive catalog.""" |
| 141 | return catalog == self.hive_catalog or catalog == self.hive_catalogs |
no outgoing calls