Search in sources :

Example 1 with LINE_DELIM

use of org.apache.hadoop.hive.ql.ddl.ShowUtils.LINE_DELIM in project hive by apache.

the class TextDescTableFormatter method getViewInfo.

private void getViewInfo(StringBuilder tableInfo, Table table, boolean isOutputPadded) {
    formatOutput("Original Query:", table.getViewOriginalText(), tableInfo);
    formatOutput("Expanded Query:", table.getViewExpandedText(), tableInfo);
    if (table.isMaterializedView()) {
        formatOutput("Rewrite Enabled:", table.isRewriteEnabled() ? "Yes" : "No", tableInfo);
        formatOutput("Outdated for Rewriting:", table.isOutdatedForRewriting() == null ? "Unknown" : table.isOutdatedForRewriting() ? "Yes" : "No", tableInfo);
        tableInfo.append(LINE_DELIM).append("# Materialized View Source table information").append(LINE_DELIM);
        TextMetaDataTable metaDataTable = new TextMetaDataTable();
        metaDataTable.addRow("Table name", "I/U/D since last rebuild");
        List<SourceTable> sourceTableList = new ArrayList<>(table.getMVMetadata().getSourceTables());
        sourceTableList.sort(Comparator.<SourceTable, String>comparing(sourceTable -> sourceTable.getTable().getDbName()).thenComparing(sourceTable -> sourceTable.getTable().getTableName()));
        for (SourceTable sourceTable : sourceTableList) {
            String qualifiedTableName = TableName.getQualified(sourceTable.getTable().getCatName(), sourceTable.getTable().getDbName(), sourceTable.getTable().getTableName());
            metaDataTable.addRow(qualifiedTableName, String.format("%d/%d/%d", sourceTable.getInsertedCount(), sourceTable.getUpdatedCount(), sourceTable.getDeletedCount()));
        }
        tableInfo.append(metaDataTable.renderTable(isOutputPadded));
    }
}
Also used : CheckConstraint(org.apache.hadoop.hive.ql.metadata.CheckConstraint) Date(java.util.Date) ConfVars(org.apache.hadoop.hive.conf.HiveConf.ConfVars) DefaultConstraintCol(org.apache.hadoop.hive.ql.metadata.DefaultConstraint.DefaultConstraintCol) StatsSetupConst(org.apache.hadoop.hive.common.StatsSetupConst) DataOutputStream(java.io.DataOutputStream) ForeignKeyInfo(org.apache.hadoop.hive.ql.metadata.ForeignKeyInfo) Map(java.util.Map) StorageDescriptor(org.apache.hadoop.hive.metastore.api.StorageDescriptor) LINE_DELIM(org.apache.hadoop.hive.ql.ddl.ShowUtils.LINE_DELIM) NotNullConstraint(org.apache.hadoop.hive.ql.metadata.NotNullConstraint) DefaultConstraint(org.apache.hadoop.hive.ql.metadata.DefaultConstraint) UniqueConstraint(org.apache.hadoop.hive.ql.metadata.UniqueConstraint) ColumnStatisticsObj(org.apache.hadoop.hive.metastore.api.ColumnStatisticsObj) Set(java.util.Set) SessionState(org.apache.hadoop.hive.ql.session.SessionState) Collectors(java.util.stream.Collectors) StandardCharsets(java.nio.charset.StandardCharsets) List(java.util.List) ForeignKeyCol(org.apache.hadoop.hive.ql.metadata.ForeignKeyInfo.ForeignKeyCol) HiveStringUtils(org.apache.hive.common.util.HiveStringUtils) UniqueConstraintCol(org.apache.hadoop.hive.ql.metadata.UniqueConstraint.UniqueConstraintCol) Entry(java.util.Map.Entry) UnsupportedEncodingException(java.io.UnsupportedEncodingException) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) DEFAULT_STRINGBUILDER_SIZE(org.apache.hadoop.hive.ql.ddl.ShowUtils.DEFAULT_STRINGBUILDER_SIZE) DescTableDesc(org.apache.hadoop.hive.ql.ddl.table.info.desc.DescTableDesc) FIELD_DELIM(org.apache.hadoop.hive.ql.ddl.ShowUtils.FIELD_DELIM) CollectionUtils(org.apache.commons.collections4.CollectionUtils) TABLE_IS_CTAS(org.apache.hadoop.hive.metastore.api.hive_metastoreConstants.TABLE_IS_CTAS) ArrayList(java.util.ArrayList) Utilities(org.apache.hadoop.hive.ql.exec.Utilities) PrimaryKeyInfo(org.apache.hadoop.hive.ql.metadata.PrimaryKeyInfo) ShowUtils.formatOutput(org.apache.hadoop.hive.ql.ddl.ShowUtils.formatOutput) ShowUtils(org.apache.hadoop.hive.ql.ddl.ShowUtils) SourceTable(org.apache.hadoop.hive.metastore.api.SourceTable) TableName(org.apache.hadoop.hive.common.TableName) TextMetaDataTable(org.apache.hadoop.hive.ql.ddl.ShowUtils.TextMetaDataTable) PlanUtils(org.apache.hadoop.hive.ql.plan.PlanUtils) MapUtils(org.apache.commons.collections4.MapUtils) PartitionTransformSpec(org.apache.hadoop.hive.ql.parse.PartitionTransformSpec) HiveConf(org.apache.hadoop.hive.conf.HiveConf) ALIGNMENT(org.apache.hadoop.hive.ql.ddl.ShowUtils.ALIGNMENT) StringEscapeUtils(org.apache.commons.text.StringEscapeUtils) Table(org.apache.hadoop.hive.ql.metadata.Table) IOException(java.io.IOException) Partition(org.apache.hadoop.hive.ql.metadata.Partition) FieldSchema(org.apache.hadoop.hive.metastore.api.FieldSchema) TreeMap(java.util.TreeMap) TableType(org.apache.hadoop.hive.metastore.TableType) Comparator(java.util.Comparator) CheckConstraintCol(org.apache.hadoop.hive.ql.metadata.CheckConstraint.CheckConstraintCol) Collections(java.util.Collections) ArrayList(java.util.ArrayList) SourceTable(org.apache.hadoop.hive.metastore.api.SourceTable) TextMetaDataTable(org.apache.hadoop.hive.ql.ddl.ShowUtils.TextMetaDataTable)

Aggregations

DataOutputStream (java.io.DataOutputStream)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 StandardCharsets (java.nio.charset.StandardCharsets)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 Date (java.util.Date)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 TreeMap (java.util.TreeMap)1 Collectors (java.util.stream.Collectors)1 CollectionUtils (org.apache.commons.collections4.CollectionUtils)1 MapUtils (org.apache.commons.collections4.MapUtils)1 StringEscapeUtils (org.apache.commons.text.StringEscapeUtils)1 StatsSetupConst (org.apache.hadoop.hive.common.StatsSetupConst)1 TableName (org.apache.hadoop.hive.common.TableName)1 HiveConf (org.apache.hadoop.hive.conf.HiveConf)1