Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ShowCreateTableStmt.java
Go to the documentation of this file.
1 // Copyright 2013 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 import com.cloudera.impala.thrift.TTableName;
22 import com.google.common.base.Preconditions;
23 
30 public class ShowCreateTableStmt extends StatementBase {
32 
34  Preconditions.checkNotNull(table);
35  this.tableName_ = table;
36  }
37 
38  @Override
39  public String toSql() { return "SHOW CREATE TABLE " + tableName_; }
40 
41  @Override
42  public void analyze(Analyzer analyzer) throws AnalysisException {
44  tableName_ = new TableName(analyzer.getDefaultDb(), tableName_.getTbl());
45  }
46  Table table = analyzer.getTable(tableName_, Privilege.VIEW_METADATA);
47  if (table instanceof View) {
48  throw new AnalysisException("SHOW CREATE TABLE not supported on VIEW: " +
49  tableName_.toString());
50  }
51  }
52 
53  public TTableName toThrift() {
54  TTableName params = new TTableName();
55  params.setTable_name(tableName_.getTbl());
56  params.setDb_name(tableName_.getDb());
57  return params;
58  }
59 }