MTable mtable = new MTable(normalizeIdentifier(tbl.getTableName()), mdb, convertToMStorageDescriptor(tbl.getSd()), tbl.getOwner(), ownerType, tbl .getCreateTime(), tbl.getLastAccessTime(), tbl.getRetention(),
return null; String tableType = mtbl.getTableType(); if (tableType == null) { if (mtbl.getViewOriginalText() != null) { tableType = TableType.VIRTUAL_VIEW.toString(); } else if (Boolean.parseBoolean(mtbl.getParameters().get("EXTERNAL"))) { tableType = TableType.EXTERNAL_TABLE.toString(); } else { final Table t = new Table(mtbl.getTableName(), mtbl.getDatabase().getName(), mtbl .getOwner(), mtbl.getCreateTime(), mtbl.getLastAccessTime(), mtbl .getRetention(), convertToStorageDescriptor(mtbl.getSd()), convertToFieldSchemas(mtbl.getPartitionKeys()), convertMap(mtbl.getParameters()), mtbl.getViewOriginalText(), mtbl.getViewExpandedText(), tableType); if (Strings.isNullOrEmpty(mtbl.getOwnerType())) { t.setOwnerType(PrincipalType.valueOf(mtbl.getOwnerType())); t.setId(mtbl.getId()); t.setRewriteEnabled(mtbl.isRewriteEnabled()); t.setCatName(mtbl.getDatabase().getCatalogName()); t.setWriteId(mtbl.getWriteId()); return t;
/** * Return true if the current statistics in the Metastore is valid * for the query of the given "txnId" and "queryValidWriteIdList". * * Note that a statistics entity is valid iff * the stats is written by the current query or * the conjunction of the following two are true: * ~ COLUMN_STATE_ACCURATE(CSA) state is true * ~ Isolation-level (snapshot) compliant with the query * @param tbl MTable of the stats entity * @param queryValidWriteIdList valid writeId list of the query * @Precondition "tbl" should be retrieved from the TBLS table. */ private boolean isCurrentStatsValidForTheQuery(MTable tbl, String queryValidWriteIdList, boolean isCompleteStatsWriter) throws MetaException { return isCurrentStatsValidForTheQuery(conf, tbl.getParameters(), tbl.getWriteId(), queryValidWriteIdList, isCompleteStatsWriter); }
oldt.setDatabase(newt.getDatabase()); oldt.setTableName(normalizeIdentifier(newt.getTableName())); boolean isTxn = TxnUtils.isTransactionalTable(newTable); boolean isToTxn = isTxn && !TxnUtils.isTransactionalTable(oldt.getParameters()); if (!isToTxn && isTxn && areTxnStatsSupported) { String errorMsg = verifyStatsChangeCtx(oldt.getParameters(), newTable.getParameters(), newTable.getWriteId(), queryValidWriteIds, false); if (errorMsg != null) { oldt.setParameters(newt.getParameters()); oldt.setOwner(newt.getOwner()); oldt.setOwnerType(newt.getOwnerType()); MStorageDescriptor oldSD = oldt.getSd(); if (oldSD != null) { oldCD = oldSD.getCD(); copyMSD(newt.getSd(), oldt.getSd()); removeUnusedColumnDescriptor(oldCD); oldt.setRetention(newt.getRetention()); oldt.setPartitionKeys(newt.getPartitionKeys()); oldt.setTableType(newt.getTableType()); oldt.setLastAccessTime(newt.getLastAccessTime()); oldt.setViewOriginalText(newt.getViewOriginalText()); oldt.setViewExpandedText(newt.getViewExpandedText()); oldt.setRewriteEnabled(newt.isRewriteEnabled()); StatsSetupConst.setBasicStatsState(oldt.getParameters(), StatsSetupConst.FALSE);
oldt.setTableName(newt.getTableName().toLowerCase()); oldt.setParameters(newt.getParameters()); oldt.setOwner(newt.getOwner()); oldt.setSd(newt.getSd()); oldt.setDatabase(newt.getDatabase()); oldt.setRetention(newt.getRetention()); oldt.setPartitionKeys(newt.getPartitionKeys()); oldt.setTableType(newt.getTableType()); oldt.setLastAccessTime(newt.getLastAccessTime());
private Partition convertToPart(MPartition mpart) throws MetaException { if (mpart == null) { return null; } //its possible that MPartition is partially filled, do null checks to avoid NPE MTable table = mpart.getTable(); String dbName = table == null ? null : table.getDatabase() == null ? null : table.getDatabase().getName(); String tableName = table == null ? null : table.getTableName(); String catName = table == null ? null : table.getDatabase() == null ? null : table.getDatabase().getCatalogName(); Partition p = new Partition(convertList(mpart.getValues()), dbName, tableName, mpart.getCreateTime(), mpart.getLastAccessTime(), convertToStorageDescriptor(mpart.getSd()), convertMap(mpart.getParameters())); p.setCatName(catName); p.setWriteId(mpart.getWriteId()); return p; }
@Override public List<Partition> getPartitionsWithAuth(String catName, String dbName, String tblName, short max, String userName, List<String> groupNames) throws MetaException, InvalidObjectException { boolean success = false; QueryWrapper queryWrapper = new QueryWrapper(); try { openTransaction(); List<MPartition> mparts = listMPartitions(catName, dbName, tblName, max, queryWrapper); List<Partition> parts = new ArrayList<>(mparts.size()); if (CollectionUtils.isNotEmpty(mparts)) { for (MPartition mpart : mparts) { MTable mtbl = mpart.getTable(); Partition part = convertToPart(mpart); parts.add(part); if ("TRUE".equalsIgnoreCase(mtbl.getParameters().get("PARTITION_LEVEL_PRIVILEGE"))) { String partName = Warehouse.makePartName(this.convertToFieldSchemas(mtbl .getPartitionKeys()), part.getValues()); PrincipalPrivilegeSet partAuth = this.getPartitionPrivilegeSet(catName, dbName, tblName, partName, userName, groupNames); part.setPrivileges(partAuth); } } } success = commitTransaction(); return parts; } finally { rollbackAndCleanup(success, queryWrapper); } }
MColumnDescriptor parentCD = retrieveCD ? nParentTable.mcd : parentTable.getSd().getCD(); int parentIntegerIndex = getColumnIndexFromTableColumns(parentCD == null ? null : parentCD.getCols(), columnName); if (parentIntegerIndex == -1) { if (parentTable.getPartitionKeys() != null) { parentCD = null; parentIntegerIndex = getColumnIndexFromTableColumns(parentTable.getPartitionKeys(), columnName);
MColumnDescriptor parentCD = retrieveCD ? nParentTable.mcd : parentTable.getSd().getCD(); int parentIntegerIndex = getColumnIndexFromTableColumns(parentCD == null ? null : parentCD.getCols(), columnName); if (parentIntegerIndex == -1) { if (parentTable.getPartitionKeys() != null) { parentCD = null; parentIntegerIndex = getColumnIndexFromTableColumns(parentTable.getPartitionKeys(), columnName); if (getPrimaryKeyConstraintName(parentTable.getDatabase().getCatalogName(), parentTable.getDatabase().getName(), parentTable.getTableName()) != null) { throw new MetaException(" Primary key already exists for: " + TableName.getQualified(catName, tableDB, tableName));
for (MTable table : tables) { TableMeta metaData = new TableMeta( table.getDatabase().getName(), table.getTableName(), table.getTableType()); metaData.setCatName(catName); metaData.setComments(table.getParameters().get("comment")); metas.add(metaData);
pm.retrieve(tbl); if (tbl != null) { materializedView = TableType.MATERIALIZED_VIEW.toString().equals(tbl.getTableType()); preDropStorageDescriptor(tbl.getSd()); dropCreationMetadata(tbl.getDatabase().getCatalogName(), tbl.getDatabase().getName(), tbl.getTableName());
openTransaction(); if (part != null) { List<MFieldSchema> schemas = part.getTable().getPartitionKeys(); List<String> colNames = new ArrayList<>(); for (MFieldSchema col: schemas) { part.getTable().getDatabase().getCatalogName(), part.getTable().getDatabase().getName(), part.getTable().getTableName(), Lists.newArrayList(partName)); part.getTable().getDatabase().getCatalogName(), part.getTable().getDatabase().getName(), part.getTable().getTableName(), Lists.newArrayList(partName)); if (CollectionUtils.isNotEmpty(partColumnGrants)) { String catName = part.getTable().getDatabase().getCatalogName(); String dbName = part.getTable().getDatabase().getName(); String tableName = part.getTable().getTableName();
MConstraint currConstraint = (MConstraint) i.next(); List<MFieldSchema> cols = currConstraint.getParentColumn() != null ? currConstraint.getParentColumn().getCols() : currConstraint.getParentTable().getPartitionKeys(); int enableValidateRely = currConstraint.getEnableValidateRely(); boolean enable = (enableValidateRely & 4) != 0;
mTbl.getParameters());
Map<String, String> newParams = new HashMap<>(table.getParameters()); StatsSetupConst.setColumnStatsState(newParams, colNames); boolean isTxn = TxnUtils.isTransactionalTable(oldt.getParameters()); if (isTxn) { if (!areTxnStatsSupported) { } else { String errorMsg = verifyStatsChangeCtx( oldt.getParameters(), newParams, writeId, validWriteIds, true); if (errorMsg != null) { throw new MetaException(errorMsg); + dbname + "." + name); oldt.setWriteId(writeId); oldt.setParameters(newParams);
boolean isTxn = TxnUtils.isTransactionalTable(table.getParameters()); if (isTxn && areTxnStatsSupported) { if (!TableType.VIRTUAL_VIEW.name().equals(oldp.getTable().getTableType())) { copyMSD(newp.getSd(), oldp.getSd());
oldt.setTableName(newt.getTableName().toLowerCase()); oldt.setParameters(newt.getParameters()); oldt.setOwner(newt.getOwner()); copyMSD(newt.getSd(), oldt.getSd()); oldt.setDatabase(newt.getDatabase()); oldt.setRetention(newt.getRetention()); oldt.setPartitionKeys(newt.getPartitionKeys()); oldt.setTableType(newt.getTableType()); oldt.setLastAccessTime(newt.getLastAccessTime()); oldt.setViewOriginalText(newt.getViewOriginalText()); oldt.setViewExpandedText(newt.getViewExpandedText());
for (MTable tbl : tbls) { result.add(new TableName( tbl.getDatabase().getCatalogName(), tbl.getDatabase().getName(), tbl.getTableName()));
"TRUE".equalsIgnoreCase(mtbl.getParameters().get("PARTITION_LEVEL_PRIVILEGE"))) { String partName = Warehouse.makePartName(this.convertToFieldSchemas(mtbl .getPartitionKeys()), part.getValues()); PrincipalPrivilegeSet partAuth = getPartitionPrivilegeSet(catName, db_name, tbl_name, partName, userName, groupNames);