15 package com.cloudera.impala.analysis;
19 import com.cloudera.impala.thrift.TAlterTableAddPartitionParams;
20 import com.cloudera.impala.thrift.TAlterTableParams;
21 import com.cloudera.impala.thrift.TAlterTableType;
22 import com.google.common.base.Preconditions;
23 import org.apache.hadoop.fs.permission.FsAction;
38 Preconditions.checkState(partitionSpec != null);
42 partitionSpec_.setTableName(tableName);
51 StringBuilder sb =
new StringBuilder(
"ALTER TABLE " +
getTbl());
54 sb.append(
"IF NOT EXISTS ");
56 sb.append(
" " + partitionSpec_.toSql());
58 sb.append(String.format(
" LOCATION '%s'",
location_));
60 if (
cacheOp_ != null) sb.append(cacheOp_.toSql());
66 TAlterTableParams params = super.toThrift();
67 params.setAlter_type(TAlterTableType.ADD_PARTITION);
68 TAlterTableAddPartitionParams addPartParams =
new TAlterTableAddPartitionParams();
69 addPartParams.setPartition_spec(partitionSpec_.toThrift());
70 addPartParams.setLocation(
location_ == null ? null : location_.toString());
72 if (
cacheOp_ != null) addPartParams.setCache_op(cacheOp_.toThrift());
73 params.setAdd_partition_params(addPartParams);
79 super.analyze(analyzer);
80 if (!
ifNotExists_) partitionSpec_.setPartitionShouldNotExist();
82 partitionSpec_.analyze(analyzer);
85 location_.analyze(analyzer,
Privilege.ALL, FsAction.READ_WRITE);
87 if (
cacheOp_ != null) cacheOp_.analyze(analyzer);
void analyze(Analyzer analyzer)
TAlterTableParams toThrift()
final PartitionSpec partitionSpec_
final boolean ifNotExists_
AlterTableAddPartitionStmt(TableName tableName, PartitionSpec partitionSpec, HdfsUri location, boolean ifNotExists, HdfsCachingOp cacheOp)
final HdfsCachingOp cacheOp_