private boolean canCopyTable() { if (!COPYABLE_TABLES.contains(this.table.getTableType())) { log.warn(String.format("Not copying %s: tables of type %s are not copyable.", this.table.getCompleteName(), this.table.getTableType())); return false; } return true; } }
private static boolean isLockableTable(Table t) { if (t.isTemporary()) { return false; } switch (t.getTableType()) { case MANAGED_TABLE: case MATERIALIZED_VIEW: return true; default: return false; } }
/** * @return whether this table is actually a view */ public boolean isView() { return TableType.VIRTUAL_VIEW.equals(getTableType()); }
/** * @return whether this table is actually an index table */ public boolean isIndexTable() { return TableType.INDEX_TABLE.equals(getTableType()); }
public boolean isMaterializedView() { return TableType.MATERIALIZED_VIEW.equals(getTableType()); }
/** * @return whether this table is actually a view */ public boolean isView() { return TableType.VIRTUAL_VIEW.equals(getTableType()); }
public boolean isMaterializedView() { return TableType.MATERIALIZED_VIEW.equals(getTableType()); }
/** * Assert it supports Acid write. */ protected void validateTargetTable(Table mTable) throws SemanticException { if (mTable.getTableType() == TableType.VIRTUAL_VIEW || mTable.getTableType() == TableType.MATERIALIZED_VIEW) { LOG.error("Table " + mTable.getFullyQualifiedName() + " is a view or materialized view"); throw new SemanticException(ErrorMsg.UPDATE_DELETE_VIEW.getMsg()); } }
public static String getPartitionInformation(Partition part) { StringBuilder tableInfo = new StringBuilder(DEFAULT_STRINGBUILDER_SIZE); // Table Metadata tableInfo.append(LINE_DELIM).append("# Detailed Partition Information").append(LINE_DELIM); getPartitionMetaDataInformation(tableInfo, part); // Storage information. if (part.getTable().getTableType() != TableType.VIRTUAL_VIEW) { tableInfo.append(LINE_DELIM).append("# Storage Information").append(LINE_DELIM); getStorageDescriptorInfo(tableInfo, part.getTPartition().getSd()); } return tableInfo.toString(); }
public static String getPartitionInformation(Partition part) { StringBuilder tableInfo = new StringBuilder(DEFAULT_STRINGBUILDER_SIZE); // Table Metadata tableInfo.append(LINE_DELIM).append("# Detailed Partition Information").append(LINE_DELIM); getPartitionMetaDataInformation(tableInfo, part); // Storage information. if (part.getTable().getTableType() != TableType.VIRTUAL_VIEW) { tableInfo.append(LINE_DELIM).append("# Storage Information").append(LINE_DELIM); getStorageDescriptorInfo(tableInfo, part.getTPartition().getSd()); } return tableInfo.toString(); }
private Task<?> dropTableTask(Table table) { assert(table != null); DropTableDesc dropTblDesc = new DropTableDesc(table.getFullyQualifiedName(), table.getTableType(), true, false, event.replicationSpec()); return TaskFactory.get(new DDLWork(new HashSet<>(), new HashSet<>(), dropTblDesc), context.hiveConf); } }
/** * Assert it supports Acid write */ private void validateTargetTable(Table mTable) throws SemanticException { if (mTable.getTableType() == TableType.VIRTUAL_VIEW || mTable.getTableType() == TableType.MATERIALIZED_VIEW) { LOG.error("Table " + getDotName(new String[] {mTable.getDbName(), mTable.getTableName()}) + " is a view or materialized view"); throw new SemanticException(ErrorMsg.UPDATE_DELETE_VIEW.getMsg()); } } /**
private void checkExternalTable(Table dest_tab) throws SemanticException { if ((!conf.getBoolVar(HiveConf.ConfVars.HIVE_INSERT_INTO_EXTERNAL_TABLES)) && (dest_tab.getTableType().equals(TableType.EXTERNAL_TABLE))) { throw new SemanticException( ErrorMsg.INSERT_EXTERNAL_TABLE.getMsg(dest_tab.getTableName())); } }
/** * Automatically serializes the {@link HiveDataset} by calling {@link #setHiveDataset(HiveDataset)} * @param hiveDataset for which the workunit is being created */ @SuppressWarnings("deprecation") public HiveWorkUnit(HiveDataset hiveDataset) { super(); setHiveDataset(hiveDataset); if (hiveDataset.getTable().getTableType() != TableType.VIRTUAL_VIEW) { setTableLocation(hiveDataset.getTable().getSd().getLocation()); } }
private static Task<?> dropTableTask(Table table, EximUtil.SemanticAnalyzerWrapperContext x, ReplicationSpec replicationSpec) { DropTableDesc dropTblDesc = new DropTableDesc(table.getTableName(), table.getTableType(), true, false, replicationSpec); return TaskFactory.get(new DDLWork(x.getInputs(), x.getOutputs(), dropTblDesc), x.getConf()); }
private void analyzeShowCreateTable(ASTNode ast) throws SemanticException { ShowCreateTableDesc showCreateTblDesc; String tableName = getUnescapedName((ASTNode)ast.getChild(0)); showCreateTblDesc = new ShowCreateTableDesc(tableName, ctx.getResFile().toString()); Table tab = getTable(tableName); if (tab.getTableType() == org.apache.hadoop.hive.metastore.TableType.INDEX_TABLE) { throw new SemanticException(ErrorMsg.SHOW_CREATETABLE_INDEX.getMsg(tableName + " has table type INDEX_TABLE")); } inputs.add(new ReadEntity(tab)); rootTasks.add(TaskFactory.get(new DDLWork(getInputs(), getOutputs(), showCreateTblDesc), conf)); setFetchTask(createFetchTask(showCreateTblDesc.getSchema())); }
private static void getTableMetaDataInformation(StringBuilder tableInfo, Table tbl, boolean isOutputPadded) { formatOutput("Database:", tbl.getDbName(), tableInfo); formatOutput("Owner:", tbl.getOwner(), tableInfo); formatOutput("CreateTime:", formatDate(tbl.getTTable().getCreateTime()), tableInfo); formatOutput("LastAccessTime:", formatDate(tbl.getTTable().getLastAccessTime()), tableInfo); formatOutput("Retention:", Integer.toString(tbl.getRetention()), tableInfo); if (!tbl.isView()) { formatOutput("Location:", tbl.getDataLocation().toString(), tableInfo); } formatOutput("Table Type:", tbl.getTableType().name(), tableInfo); if (tbl.getParameters().size() > 0) { tableInfo.append("Table Parameters:").append(LINE_DELIM); displayAllParameters(tbl.getParameters(), tableInfo, false, isOutputPadded); } }
private static void getTableMetaDataInformation(StringBuilder tableInfo, Table tbl, boolean isOutputPadded) { formatOutput("Database:", tbl.getDbName(), tableInfo); formatOutput("OwnerType:", (tbl.getOwnerType() != null) ? tbl.getOwnerType().name() : "null", tableInfo); formatOutput("Owner:", tbl.getOwner(), tableInfo); formatOutput("CreateTime:", formatDate(tbl.getTTable().getCreateTime()), tableInfo); formatOutput("LastAccessTime:", formatDate(tbl.getTTable().getLastAccessTime()), tableInfo); formatOutput("Retention:", Integer.toString(tbl.getRetention()), tableInfo); if (!tbl.isView()) { formatOutput("Location:", tbl.getDataLocation().toString(), tableInfo); } formatOutput("Table Type:", tbl.getTableType().name(), tableInfo); if (tbl.getParameters().size() > 0) { tableInfo.append("Table Parameters:").append(LINE_DELIM); displayAllParameters(tbl.getParameters(), tableInfo, false, isOutputPadded); } }
@Override public RelNode visit(TableScan scan) { if (scan instanceof HiveTableScan) { HiveTableScan hiveScan = (HiveTableScan) scan; RelOptHiveTable relOptHiveTable = (RelOptHiveTable) hiveScan.getTable(); Table tab = relOptHiveTable.getHiveTableMD(); if (tab.isTemporary()) { fail(tab.getTableName() + " is a temporary table"); } if (tab.getTableType() == TableType.EXTERNAL_TABLE) { fail(tab.getFullyQualifiedName() + " is an external table"); } return scan; } // TableScan of a non-Hive table - don't support for materializations. fail(scan.getTable().getQualifiedName() + " is a table scan of a non-Hive table."); return scan; }
void dumpTable(String dbName, String tblName, String validTxnList, Path dbRoot, long lastReplId, Hive hiveDb, HiveWrapper.Tuple<Table> tuple) throws Exception { TableSpec tableSpec = new TableSpec(tuple.object); TableExport.Paths exportPaths = new TableExport.Paths(work.astRepresentationForErrorMsg, dbRoot, tblName, conf, true); String distCpDoAsUser = conf.getVar(HiveConf.ConfVars.HIVE_DISTCP_DOAS_USER); tuple.replicationSpec.setIsReplace(true); // by default for all other objects this is false if (AcidUtils.isTransactionalTable(tableSpec.tableHandle)) { tuple.replicationSpec.setValidTxnList(validTxnList); tuple.replicationSpec.setValidWriteIdList(getValidWriteIdList(dbName, tblName, validTxnList)); // For transactional table, data would be valid snapshot for current txn and doesn't include data // added/modified by concurrent txns which are later than current txn. So, need to set last repl Id of this table // as bootstrap dump's last repl Id. tuple.replicationSpec.setCurrentReplicationState(String.valueOf(lastReplId)); // For now we do not replicate stats for ACID table. So, wipe out column stats if any. tableSpec.tableHandle.getTTable().unsetColStats(); } MmContext mmCtx = MmContext.createIfNeeded(tableSpec.tableHandle); new TableExport( exportPaths, tableSpec, tuple.replicationSpec, hiveDb, distCpDoAsUser, conf, mmCtx).write(); replLogger.tableLog(tblName, tableSpec.tableHandle.getTableType()); }