Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
AlterTableSetCachedStmt.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 
20 import com.cloudera.impala.thrift.TAlterTableParams;
21 import com.cloudera.impala.thrift.TAlterTableSetCachedParams;
22 import com.cloudera.impala.thrift.TAlterTableType;
23 import com.google.common.base.Preconditions;
24 
29  private final HdfsCachingOp cacheOp_;
30 
32  PartitionSpec partitionSpec, HdfsCachingOp cacheOp) {
33  super(tableName, partitionSpec);
34  Preconditions.checkNotNull(cacheOp);
35  cacheOp_ = cacheOp;
36  }
37 
38  @Override
39  public TAlterTableParams toThrift() {
40  TAlterTableParams params = super.toThrift();
41  params.setAlter_type(TAlterTableType.SET_CACHED);
42  TAlterTableSetCachedParams cachingParams =
43  new TAlterTableSetCachedParams();
44  if (getPartitionSpec() != null) {
45  cachingParams.setPartition_spec(getPartitionSpec().toThrift());
46  }
47  cachingParams.setCache_op(cacheOp_.toThrift());
48  params.setSet_cached_params(cachingParams);
49  return params;
50  }
51 
52  @Override
53  public void analyze(Analyzer analyzer) throws AnalysisException {
54  super.analyze(analyzer);
55  cacheOp_.analyze(analyzer);
56 
57  Table table = getTargetTable();
58  Preconditions.checkNotNull(table);
59  if (!(table instanceof HdfsTable)) {
60  throw new AnalysisException("ALTER TABLE SET [CACHED|UNCACHED] must target an " +
61  "HDFS table: " + table.getFullName());
62  }
63  }
64 }
AlterTableSetCachedStmt(TableName tableName, PartitionSpec partitionSpec, HdfsCachingOp cacheOp)