Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
AlterTableSetStmt.java
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 package com.cloudera.impala.analysis;
16 
21 
25 public class AlterTableSetStmt extends AlterTableStmt {
26  protected final PartitionSpec partitionSpec_;
27 
28  public AlterTableSetStmt(TableName tableName, PartitionSpec partitionSpec) {
29  super(tableName);
30  partitionSpec_ = partitionSpec;
31  if (partitionSpec_ != null) partitionSpec_.setTableName(tableName);
32  }
33 
35 
36  @Override
37  public void analyze(Analyzer analyzer) throws AnalysisException {
38  super.analyze(analyzer);
39  Table t = getTargetTable();
40  // TODO: Support ALTER TABLE SET on HBase tables. Requires validating changes
41  // to the SERDEPROPERTIES and TBLPROPERTIES to ensure the table metadata does not
42  // become invalid.
43  if (t instanceof HBaseTable) {
44  throw new AnalysisException("ALTER TABLE SET not currently supported on " +
45  "HBase tables.");
46  }
47 
48  // Altering the table rather than the partition.
49  if (partitionSpec_ == null) return;
50 
51  partitionSpec_.setPartitionShouldExist();
52  partitionSpec_.setPrivilegeRequirement(Privilege.ALTER);
53  partitionSpec_.analyze(analyzer);
54  }
55 }
AlterTableSetStmt(TableName tableName, PartitionSpec partitionSpec)