private static class ThreadLocalHive extends ThreadLocal<Hive> { @Override protected Hive initialValue() { return null; } @Override public synchronized void set(Hive hiveObj) { Hive currentHive = this.get(); if (currentHive != hiveObj) { // Remove/close current thread-local Hive object before overwriting with new Hive object. remove(); super.set(hiveObj); } } @Override public synchronized void remove() { Hive currentHive = this.get(); if (currentHive != null) { // Close the metastore connections before removing it from thread local hiveDB. currentHive.close(false); super.remove(); } } }
public void alterTable(String tblName, Table newTbl, boolean cascade, EnvironmentContext environmentContext) throws InvalidOperationException, HiveException { String[] names = Utilities.getDbTableName(tblName); try { // Remove the DDL_TIME so it gets refreshed if (newTbl.getParameters() != null) { newTbl.getParameters().remove(hive_metastoreConstants.DDL_TIME); } newTbl.checkValidity(conf); if (environmentContext == null) { environmentContext = new EnvironmentContext(); } if (cascade) { environmentContext.putToProperties(StatsSetupConst.CASCADE, StatsSetupConst.TRUE); } getMSC().alter_table_with_environmentContext(names[0], names[1], newTbl.getTTable(), environmentContext); } catch (MetaException e) { throw new HiveException("Unable to alter table. " + e.getMessage(), e); } catch (TException e) { throw new HiveException("Unable to alter table. " + e.getMessage(), e); } }
newTbl.getParameters().remove(hive_metastoreConstants.DDL_TIME); newTbl.checkValidity(conf); if (environmentContext == null) { environmentContext = new EnvironmentContext();
tbl.checkValidity(conf); } else { for (Partition tmpPart: allPartitions) {
tbl.getDeserializer())); tbl.checkValidity(conf); if (tbl.getParameters() != null) { tbl.getParameters().remove(hive_metastoreConstants.DDL_TIME);
tbl.checkValidity(conf); } else { for (Partition tmpPart: allPartitions) {
ft.checkValidity(hiveConf); assertEquals("Table names didn't match for table: " + tableName, tbl .getTableName(), ft.getTableName());
oldview.setOutputFormatClass(crtView.getOutputFormat()); oldview.checkValidity(null); db.alterTable(crtView.getViewName(), oldview, false, null, true); addIfAbsentByName(new WriteEntity(oldview, WriteEntity.WriteType.DDL_NO_LOCK));
oldview.setOutputFormatClass(crtView.getOutputFormat()); oldview.checkValidity(null); try { db.alterTable(crtView.getViewName(), oldview, null);
public void alterTable(String tblName, Table newTbl, boolean cascade) throws InvalidOperationException, HiveException { String[] names = Utilities.getDbTableName(tblName); try { // Remove the DDL_TIME so it gets refreshed if (newTbl.getParameters() != null) { newTbl.getParameters().remove(hive_metastoreConstants.DDL_TIME); } newTbl.checkValidity(); getMSC().alter_table(names[0], names[1], newTbl.getTTable(), cascade); } catch (MetaException e) { throw new HiveException("Unable to alter table. " + e.getMessage(), e); } catch (TException e) { throw new HiveException("Unable to alter table. " + e.getMessage(), e); } }
table.checkValidity(); return table;
tbl.getDeserializer())); tbl.checkValidity(); if (tbl.getParameters() != null) { tbl.getParameters().remove(Constants.DDL_TIME);
tbl.checkValidity(); } else { for (Partition tmpPart: allPartitions) {
tbl.getDeserializer())); tbl.checkValidity(); if (tbl.getParameters() != null) { tbl.getParameters().remove(hive_metastoreConstants.DDL_TIME);
tbl.checkValidity(); } catch (HiveException e) { console.printError("Invalid table columns : " + e.getMessage(),
oldview.checkValidity(); try { db.alterTable(crtView.getViewName(), oldview);