public static String getAllColumnsInformation(List<FieldSchema> cols) { StringBuilder columnInformation = new StringBuilder(DEFAULT_STRINGBUILDER_SIZE); formatColumnsHeader(columnInformation); formatAllFields(columnInformation, cols); return columnInformation.toString(); }
private static void formatAllFields(StringBuilder tableInfo, List<FieldSchema> cols) { for (FieldSchema col : cols) { formatFieldSchemas(tableInfo, col); } }
private static void formatColumnsHeader(StringBuilder columnInformation) { columnInformation.append("# "); // Easy for shell scripts to ignore formatOutput(getColumnsHeader(), columnInformation); columnInformation.append(LINE_DELIM); }
cols.addAll(tbl.getPartCols()); outStream.writeBytes(MetaDataFormatUtils.displayColsUnformatted(cols)); } else { outStream.writeBytes(MetaDataFormatUtils.getAllColumnsInformation(tbl)); outStream.writeBytes(MetaDataFormatUtils.getAllColumnsInformation(cols)); } else { outStream.writeBytes(MetaDataFormatUtils.displayColsUnformatted(cols)); outStream.writeBytes(MetaDataFormatUtils.getPartitionInformation(part)); } else { outStream.writeBytes(MetaDataFormatUtils.getTableInformation(tbl));
private static void getTableMetaDataInformation(StringBuilder tableInfo, Table tbl) { formatOutput("Database:", tbl.getDbName(), tableInfo); formatOutput("Owner:", tbl.getOwner(), tableInfo); formatOutput("CreateTime:", formatDate(tbl.getTTable().getCreateTime()), tableInfo); formatOutput("LastAccessTime:", formatDate(tbl.getTTable().getLastAccessTime()), tableInfo); String protectMode = tbl.getProtectMode().toString(); formatOutput("Protect Mode:", protectMode == null ? "None" : protectMode, 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); } }
private static void getStorageDescriptorInfo(StringBuilder tableInfo, StorageDescriptor storageDesc) { formatOutput("SerDe Library:", storageDesc.getSerdeInfo().getSerializationLib(), tableInfo); formatOutput("InputFormat:", storageDesc.getInputFormat(), tableInfo); formatOutput("OutputFormat:", storageDesc.getOutputFormat(), tableInfo); formatOutput("Compressed:", storageDesc.isCompressed() ? "Yes" : "No", tableInfo); formatOutput("Num Buckets:", String.valueOf(storageDesc.getNumBuckets()), tableInfo); formatOutput("Bucket Columns:", storageDesc.getBucketCols().toString(), tableInfo); formatOutput("Sort Columns:", storageDesc.getSortCols().toString(), tableInfo); if (storageDesc.getSerdeInfo().getParametersSize() > 0) { tableInfo.append("Storage Desc Params:").append(LINE_DELIM); displayAllParameters(storageDesc.getSerdeInfo().getParameters(), tableInfo); } }
private static void displayAllParameters(Map<String, String> params, StringBuilder tableInfo) { List<String> keys = new ArrayList<String>(params.keySet()); Collections.sort(keys); for (String key : keys) { tableInfo.append(FIELD_DELIM); // Ensures all params are indented. formatOutput(key, StringEscapeUtils.escapeJava(params.get(key)), tableInfo); } }
outStream.writeBytes(MetaDataFormatUtils.getIndexColumnsHeader()); outStream.write(terminator); outStream.write(terminator); outStream.writeBytes(MetaDataFormatUtils.getAllColumnsInformation(index));
private static void getPartitionMetaDataInformation(StringBuilder tableInfo, Partition part) { formatOutput("Partition Value:", part.getValues().toString(), tableInfo); formatOutput("Database:", part.getTPartition().getDbName(), tableInfo); formatOutput("Table:", part.getTable().getTableName(), tableInfo); formatOutput("CreateTime:", formatDate(part.getTPartition().getCreateTime()), tableInfo); formatOutput("LastAccessTime:", formatDate(part.getTPartition().getLastAccessTime()), tableInfo); String protectMode = part.getProtectMode().toString(); formatOutput("Protect Mode:", protectMode == null ? "None" : protectMode, tableInfo); formatOutput("Location:", part.getLocation(), tableInfo); if (part.getTPartition().getParameters().size() > 0) { tableInfo.append("Partition Parameters:").append(LINE_DELIM); displayAllParameters(part.getTPartition().getParameters(), tableInfo); } }
public static String getIndexColumnsHeader() { StringBuilder indexCols = new StringBuilder(DEFAULT_STRINGBUILDER_SIZE); formatOutput(ShowIndexesDesc.getSchema().split("#")[0].split(","), indexCols); return indexCols.toString(); } }
public static String getAllColumnsInformation(Table table) { StringBuilder columnInformation = new StringBuilder(DEFAULT_STRINGBUILDER_SIZE); formatColumnsHeader(columnInformation); formatAllFields(columnInformation, table.getCols()); // Partitions if (table.isPartitioned()) { columnInformation.append(LINE_DELIM).append("# Partition Information") .append(LINE_DELIM); formatColumnsHeader(columnInformation); formatAllFields(columnInformation, table.getPartCols()); } return columnInformation.toString(); }
private static void getViewInfo(StringBuilder tableInfo, Table tbl) { formatOutput("View Original Text:", tbl.getViewOriginalText(), tableInfo); formatOutput("View Expanded Text:", tbl.getViewExpandedText(), tableInfo); }
formatOutput(indexColumns.toArray(new String[0]), indexInfo);
private static void formatFieldSchemas(StringBuilder tableInfo, FieldSchema col) { String comment = col.getComment() != null ? col.getComment() : "None"; formatOutput(col.getName(), col.getType(), comment, tableInfo); }