Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
DescribeStmt.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 
19 import com.cloudera.impala.thrift.TDescribeTableOutputStyle;
20 import com.cloudera.impala.thrift.TDescribeTableParams;
21 
33 public class DescribeStmt extends StatementBase {
34  private final TDescribeTableOutputStyle outputStyle_;
36 
37  public DescribeStmt(TableName tableName, TDescribeTableOutputStyle outputStyle) {
38  this.tableName_ = tableName;
39  this.outputStyle_ = outputStyle;
40  }
41 
42  @Override
43  public String toSql() {
44  StringBuilder sb = new StringBuilder("DESCRIBE ");
45  if (outputStyle_ != TDescribeTableOutputStyle.MINIMAL) {
46  sb.append(outputStyle_.toString());
47  }
48  return sb.toString() + tableName_;
49  }
50 
51  public TableName getTable() { return tableName_; }
52  public TDescribeTableOutputStyle getOutputStyle() { return outputStyle_; }
53 
54  @Override
55  public void analyze(Analyzer analyzer) throws AnalysisException {
57  tableName_ = new TableName(analyzer.getDefaultDb(), tableName_.getTbl());
58  }
59  analyzer.getTable(tableName_, Privilege.VIEW_METADATA);
60  }
61 
62  public TDescribeTableParams toThrift() {
63  TDescribeTableParams params = new TDescribeTableParams();
64  params.setTable_name(getTable().getTbl());
65  params.setDb(getTable().getDb());
66  params.setOutput_style(outputStyle_);
67  return params;
68  }
69 }
DescribeStmt(TableName tableName, TDescribeTableOutputStyle outputStyle)
final TDescribeTableOutputStyle outputStyle_
TDescribeTableOutputStyle getOutputStyle()