Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ShowDbsStmt.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 
18 import com.cloudera.impala.thrift.TShowDbsParams;
19 
30 public class ShowDbsStmt extends StatementBase {
31  // Pattern to match tables against. | denotes choice, * matches all strings
32  private final String pattern_;
33 
38  public ShowDbsStmt() {
39  this(null);
40  }
41 
46  public ShowDbsStmt(String pattern) {
47  this.pattern_ = pattern;
48  }
49 
50  public String getPattern() { return pattern_; }
51 
52  @Override
53  public String toSql() {
54  if (pattern_ == null) {
55  return "SHOW DATABASES";
56  } else {
57  return "SHOW DATABASES LIKE '" + pattern_ + "'";
58  }
59  }
60 
61  @Override
62  public void analyze(Analyzer analyzer) throws AnalysisException {
63  // Nothing to do here
64  }
65 
66  public TShowDbsParams toThrift() {
67  TShowDbsParams params = new TShowDbsParams();
68  params.setShow_pattern(getPattern());
69  return params;
70  }
71 }