@@ -194,36 +194,14 @@ public static boolean dropTable(Configuration conf, Properties props) {
194194 */
195195 public static boolean hiveCatalog (Configuration conf , Properties props ) {
196196 String catalogName = props .getProperty (InputFormatConfig .TABLE_CATALOG );
197- if (catalogName != null ) {
198- return HIVE .equalsIgnoreCase (conf .get (String .format (InputFormatConfig .CATALOG_TYPE_TEMPLATE , catalogName )));
199- } else {
200- if (HIVE .equalsIgnoreCase (conf .get (String .format (InputFormatConfig .CATALOG_TYPE_TEMPLATE , DEFAULT_CATALOG )))) {
201- return true ;
202- } else {
203- return HIVE .equalsIgnoreCase (conf .get (InputFormatConfig .CATALOG ));
204- }
205- }
197+ return HIVE .equalsIgnoreCase (getCatalogType (conf , catalogName ));
206198 }
207199
208200 @ VisibleForTesting
209201 static Optional <Catalog > loadCatalog (Configuration conf , String catalogName ) {
210- String catalogType ;
211202 String name = catalogName == null ? DEFAULT_CATALOG : catalogName ;
212- catalogType = conf .get (String .format (InputFormatConfig .CATALOG_TYPE_TEMPLATE , name ));
213-
214- // keep both catalog configuration methods for seamless transition
215- if (catalogType != null ) {
216- // new logic
217- LOG .debug ("Using catalog configuration from table properties." );
218- return loadCatalog (conf , name , catalogType );
219- } else {
220- // old logic
221- // use catalog {@link InputFormatConfig.CATALOG} stored in global hive config if table specific catalog
222- // configuration or default catalog definition is missing
223- LOG .debug ("Using catalog configuration from global configuration." );
224- catalogType = conf .get (InputFormatConfig .CATALOG );
225- return loadCatalog (conf , name , catalogType );
226- }
203+ String catalogType = getCatalogType (conf , name );
204+ return loadCatalog (conf , name , catalogType );
227205 }
228206
229207 private static Optional <Catalog > loadCatalog (Configuration conf , String catalogName , String catalogType ) {
@@ -237,8 +215,7 @@ private static Optional<Catalog> loadCatalog(Configuration conf, String catalogN
237215 switch (catalogType .toLowerCase ()) {
238216 case HADOOP :
239217 if (properties .containsKey (CatalogProperties .WAREHOUSE_LOCATION )) {
240- catalog = CatalogUtil .loadCatalog (HadoopCatalog .class .getName (), catalogName ,
241- getCatalogProperties (conf , catalogName ), conf );
218+ catalog = CatalogUtil .loadCatalog (HadoopCatalog .class .getName (), catalogName , properties , conf );
242219 } else {
243220 String warehouseLocation = conf .get (InputFormatConfig .HADOOP_CATALOG_WAREHOUSE_LOCATION );
244221 catalog = (warehouseLocation != null ) ? new HadoopCatalog (conf , warehouseLocation ) : new HadoopCatalog (conf );
@@ -282,4 +259,17 @@ private static Map<String, String> getCatalogProperties(Configuration conf, Stri
282259 });
283260 return properties ;
284261 }
262+
263+ private static String getCatalogType (Configuration conf , String catalogName ) {
264+ String name = catalogName == null ? DEFAULT_CATALOG : catalogName ;
265+ String catalogType = conf .get (String .format (InputFormatConfig .CATALOG_TYPE_TEMPLATE , name ));
266+ // keep both catalog configuration methods for seamless transition
267+ if (catalogType != null ) {
268+ LOG .debug ("Using catalog configuration from table properties." );
269+ return catalogType ;
270+ } else {
271+ LOG .debug ("Using catalog configuration from global configuration." );
272+ return conf .get (InputFormatConfig .CATALOG );
273+ }
274+ }
285275}
0 commit comments