@Override public String mapToClientType(String hiveTypeName) { try { TableType hiveType = TableType.valueOf(hiveTypeName.toUpperCase()); return hiveType.name(); } catch (IllegalArgumentException e) { LOG.warn("Invalid hive table type " + hiveTypeName); return hiveTypeName; } }
TableType tableType = TableType.valueOf(table.getTableType()); checkArgument(EnumSet.of(MANAGED_TABLE, EXTERNAL_TABLE).contains(tableType), "Invalid table type: %s", tableType);
for (String type : tableTypes.split(",")) { try { tableTypesSet.add(TableType.valueOf(type.trim().toUpperCase()).name()); } catch (IllegalArgumentException e) {
public static List<Task<? extends Serializable>> addOpenTxnTaskForMigration(String actualDbName, String actualTblName, HiveConf conf, UpdatedMetaDataTracker updatedMetaDataTracker, Task<? extends Serializable> childTask, org.apache.hadoop.hive.metastore.api.Table tableObj) throws IOException, TException { List<Task<? extends Serializable>> taskList = new ArrayList<>(); taskList.add(childTask); if (conf.getBoolVar(HiveConf.ConfVars.HIVE_STRICT_MANAGED_TABLES) && updatedMetaDataTracker != null && !AcidUtils.isTransactionalTable(tableObj) && TableType.valueOf(tableObj.getTableType()) == TableType.MANAGED_TABLE) { //TODO : isPathOwnByHive is hard coded to true, need to get it from repl dump metadata. HiveStrictManagedMigration.TableMigrationOption migrationOption = HiveStrictManagedMigration.determineMigrationTypeAutomatically(tableObj, TableType.MANAGED_TABLE, null, conf, null, true); if (migrationOption == MANAGED) { //if conversion to managed table. Task<? extends Serializable> replTxnTask = TaskFactory.get(new ReplTxnWork(actualDbName, actualTblName, ReplTxnWork.OperationType.REPL_MIGRATION_OPEN_TXN), conf); replTxnTask.addDependentTask(childTask); updatedMetaDataTracker.setNeedCommitTxn(true); taskList.add(replTxnTask); } } return taskList; } }
TableType tableType = TableType.valueOf(tableObj.getTableType()); getHiveUpdater(), hms, conf); if (!failedValidationChecks && (TableType.valueOf(tableObj.getTableType()) == TableType.MANAGED_TABLE)) { Path tablePath = new Path(tableObj.getSd().getLocation()); if (modifyDefaultManagedLocation && shouldModifyTableLocation(dbObj, tableObj)) {
@Override public synchronized void createTable(Table table) TableType tableType = TableType.valueOf(table.getTableType()); checkArgument(EnumSet.of(MANAGED_TABLE, EXTERNAL_TABLE, VIRTUAL_VIEW).contains(tableType), "Invalid table type: %s", tableType);
@Override public List<String> get_tables_by_type(final String dbname, final String pattern, final String tableType) throws MetaException { startFunction("get_tables_by_type", ": db=" + dbname + " pat=" + pattern + ",type=" + tableType); List<String> ret = null; Exception ex = null; String[] parsedDbName = parseDbName(dbname, conf); try { ret = getMS().getTables(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], pattern, TableType.valueOf(tableType)); } catch (MetaException e) { ex = e; throw e; } catch (Exception e) { ex = e; throw newMetaException(e); } finally { endFunction("get_tables_by_type", ret != null, ex); } return ret; }
private static void upgradeTableDesc(org.apache.hadoop.hive.metastore.api.Table tableObj, MetaData rv, EximUtil.SemanticAnalyzerWrapperContext x) throws IOException, TException, HiveException { x.getLOG().debug("Converting table " + tableObj.getTableName() + " of type " + tableObj.getTableType() + " with para " + tableObj.getParameters()); //TODO : isPathOwnedByHive is hard coded to true, need to get it from repl dump metadata. TableType tableType = TableType.valueOf(tableObj.getTableType()); HiveStrictManagedMigration.TableMigrationOption migrationOption = HiveStrictManagedMigration.determineMigrationTypeAutomatically(tableObj, tableType, null, x.getConf(), x.getHive().getMSC(), true); HiveStrictManagedMigration.migrateTable(tableObj, tableType, migrationOption, false, getHiveUpdater(x.getConf()), x.getHive().getMSC(), x.getConf()); x.getLOG().debug("Converted table " + tableObj.getTableName() + " of type " + tableObj.getTableType() + " with para " + tableObj.getParameters()); }
/** * Checks if the table is valid based on the rules for strict managed tables. * @param conf * @param table * @return Null if the table is valid, otherwise a string message indicating why the table is invalid. */ public static String validateStrictManagedTable(Configuration conf, Table table) { if (MetastoreConf.getBoolVar(conf, MetastoreConf.ConfVars.STRICT_MANAGED_TABLES)) { if (table.isTemporary()) { // temp tables exempted from checks. return null; } TableType tableType = TableType.valueOf(table.getTableType()); if (tableType == TableType.MANAGED_TABLE) { if (!MetaStoreServerUtils.isTransactionalTable(table.getParameters())) { return createValidationError(table, "Table is marked as a managed table but is not transactional."); } if (MetaStoreUtils.isNonNativeTable(table)) { return createValidationError(table, "Table is marked as a managed table but is non-native."); } if (isAvroTableWithExternalSchema(table)) { return createValidationError(table, "Managed Avro table has externally defined schema."); } } } // Table is valid return null; }
@Override public String mapToClientType(String hiveTypeName) { try { TableType hiveType = TableType.valueOf(hiveTypeName.toUpperCase()); return hiveType.name(); } catch (IllegalArgumentException e) { LOG.warn("Invalid hive table type " + hiveTypeName); return hiveTypeName; } }
TableType tableType = TableType.valueOf(table.getTableType()); checkArgument(EnumSet.of(MANAGED_TABLE, EXTERNAL_TABLE).contains(tableType), "Invalid table type: %s", tableType);
@Override public Table run(HiveMetaStoreClient client) throws TException { try{ Table table = client.getTable(dbName, tableName); if(table == null){ return null; } TableType type = TableType.valueOf(table.getTableType()); switch(type){ case EXTERNAL_TABLE: case MANAGED_TABLE: return table; case VIRTUAL_VIEW: throw UserException.unsupportedError().message("Hive views are not supported").build(logger); case INDEX_TABLE: default: return null; } }catch(NoSuchObjectException e){ return null; } }}); }
@Override public List<String> get_tables_by_type(final String dbname, final String pattern, final String tableType) throws MetaException { startFunction("get_tables_by_type", ": db=" + dbname + " pat=" + pattern + ",type=" + tableType); List<String> ret = null; Exception ex = null; String[] parsedDbName = parseDbName(dbname, conf); try { ret = getMS().getTables(parsedDbName[CAT_NAME], parsedDbName[DB_NAME], pattern, TableType.valueOf(tableType)); } catch (Exception e) { ex = e; if (e instanceof MetaException) { throw (MetaException) e; } else { throw newMetaException(e); } } finally { endFunction("get_tables_by_type", ret != null, ex); } return ret; }
@Override public synchronized void createTable(Table table) { TableType tableType = TableType.valueOf(table.getTableType()); checkArgument(EnumSet.of(MANAGED_TABLE, EXTERNAL_TABLE, VIRTUAL_VIEW).contains(tableType), "Invalid table type: %s", tableType); if (tableType == VIRTUAL_VIEW) { checkArgument(table.getSd().getLocation() == null, "Storage location for view must be null"); } else { File directory = new File(new Path(table.getSd().getLocation()).toUri()); checkArgument(directory.exists(), "Table directory does not exist"); if (tableType == MANAGED_TABLE) { checkArgument(isParentDir(directory, baseDirectory), "Table directory must be inside of the metastore base directory"); } } SchemaTableName schemaTableName = new SchemaTableName(table.getDbName(), table.getTableName()); Table tableCopy = table.deepCopy(); if (relations.putIfAbsent(schemaTableName, tableCopy) != null) { throw new TableAlreadyExistsException(schemaTableName); } if (tableType == VIRTUAL_VIEW) { views.put(schemaTableName, tableCopy); } PrincipalPrivilegeSet privileges = table.getPrivileges(); if (privileges != null) { throw new UnsupportedOperationException(); } }
@Override public synchronized void createTable(Table table) { TableType tableType = TableType.valueOf(table.getTableType()); checkArgument(EnumSet.of(MANAGED_TABLE, EXTERNAL_TABLE, VIRTUAL_VIEW).contains(tableType), "Invalid table type: %s", tableType); if (tableType == VIRTUAL_VIEW) { checkArgument(table.getSd().getLocation() == null, "Storage location for view must be null"); } else { File directory = new File(new Path(table.getSd().getLocation()).toUri()); checkArgument(directory.exists(), "Table directory does not exist"); if (tableType == MANAGED_TABLE) { checkArgument(isParentDir(directory, baseDirectory), "Table directory must be inside of the metastore base directory"); } } SchemaTableName schemaTableName = new SchemaTableName(table.getDbName(), table.getTableName()); Table tableCopy = table.deepCopy(); if (relations.putIfAbsent(schemaTableName, tableCopy) != null) { throw new TableAlreadyExistsException(schemaTableName); } if (tableType == VIRTUAL_VIEW) { views.put(schemaTableName, tableCopy); } PrincipalPrivilegeSet privileges = table.getPrivileges(); if (privileges != null) { throw new UnsupportedOperationException(); } }
@Override public synchronized void createTable(Table table) TableType tableType = TableType.valueOf(table.getTableType()); checkArgument(EnumSet.of(MANAGED_TABLE, EXTERNAL_TABLE, VIRTUAL_VIEW).contains(tableType), "Invalid table type: %s", tableType);
partition.setValues(Lists.newArrayList(partitionKeyValues.values())); StorageDescriptor psd = new StorageDescriptor(table.getSd()); TableType tableType = TableType.valueOf(table.getTableType()); if (tableType.equals(TableType.MANAGED_TABLE) || tableType.equals(TableType.EXTERNAL_TABLE)) {
partition.setValues(Lists.newArrayList(partitionKeyValues.values())); StorageDescriptor psd = new StorageDescriptor(table.getSd()); TableType tableType = TableType.valueOf(table.getTableType()); if (tableType.equals(TableType.MANAGED_TABLE) || tableType.equals(TableType.EXTERNAL_TABLE)) {