Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
AlterTableSetTblProperties.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 
17 import java.util.HashMap;
18 
19 import com.cloudera.impala.thrift.TAlterTableParams;
20 import com.cloudera.impala.thrift.TAlterTableSetTblPropertiesParams;
21 import com.cloudera.impala.thrift.TAlterTableType;
22 import com.cloudera.impala.thrift.TTablePropertyType;
23 import com.google.common.base.Preconditions;
24 
30  private final TTablePropertyType targetProperty_;
31  private final HashMap<String, String> tblProperties_;
32 
33  public AlterTableSetTblProperties(TableName tableName, PartitionSpec partitionSpec,
34  TTablePropertyType targetProperty, HashMap<String, String> tblProperties) {
35  super(tableName, partitionSpec);
36  Preconditions.checkNotNull(tblProperties);
37  Preconditions.checkNotNull(targetProperty);
38  targetProperty_ = targetProperty;
39  tblProperties_ = tblProperties;
40  CreateTableStmt.unescapeProperties(tblProperties_);
41  }
42 
43  public HashMap<String, String> getTblProperties() { return tblProperties_; }
44 
45  @Override
46  public TAlterTableParams toThrift() {
47  TAlterTableParams params = super.toThrift();
48  params.setAlter_type(TAlterTableType.SET_TBL_PROPERTIES);
49  TAlterTableSetTblPropertiesParams tblPropertyParams =
50  new TAlterTableSetTblPropertiesParams();
51  tblPropertyParams.setTarget(targetProperty_);
52  tblPropertyParams.setProperties(tblProperties_);
53  if (partitionSpec_ != null) {
54  tblPropertyParams.setPartition_spec(partitionSpec_.toThrift());
55  }
56  params.setSet_tbl_properties_params(tblPropertyParams);
57  return params;
58  }
59 }
AlterTableSetTblProperties(TableName tableName, PartitionSpec partitionSpec, TTablePropertyType targetProperty, HashMap< String, String > tblProperties)