15 package com.cloudera.impala.analysis;
17 import java.util.List;
20 import org.apache.hadoop.hive.metastore.api.FieldSchema;
26 import com.cloudera.impala.thrift.TAlterTableAddReplaceColsParams;
27 import com.cloudera.impala.thrift.TAlterTableParams;
28 import com.cloudera.impala.thrift.TAlterTableType;
29 import com.google.common.base.Preconditions;
30 import com.google.common.collect.Lists;
31 import com.google.common.collect.Sets;
41 boolean replaceExistingCols) {
43 Preconditions.checkState(columnDefs != null && columnDefs.size() > 0);
57 TAlterTableParams params = super.toThrift();
58 params.setAlter_type(TAlterTableType.ADD_REPLACE_COLUMNS);
59 TAlterTableAddReplaceColsParams colParams =
new TAlterTableAddReplaceColsParams();
61 colParams.addToColumns(col.toThrift());
64 params.setAdd_replace_cols_params(colParams);
70 super.analyze(analyzer);
76 "supported on HBase tables.");
80 Set<String> existingPartitionKeys = Sets.newHashSet();
81 for (FieldSchema fs: t.getMetaStoreTable().getPartitionKeys()) {
82 existingPartitionKeys.add(fs.getName().toLowerCase());
88 Set<String> colNames = Sets.newHashSet();
91 String colName = c.getColName().toLowerCase();
92 if (existingPartitionKeys.contains(colName)) {
94 "Column name conflicts with existing partition column: " + colName);
97 Column col = t.getColumn(colName);
100 }
else if (!colNames.add(colName)) {
void analyze(Analyzer analyzer)
final boolean replaceExistingCols_
final List< ColumnDef > columnDefs_
List< ColumnDef > getColumnDescs()
boolean getReplaceExistingCols()
TAlterTableParams toThrift()
AlterTableAddReplaceColsStmt(TableName tableName, List< ColumnDef > columnDefs, boolean replaceExistingCols)