Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
DropDbStmt.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
com.cloudera.impala.authorization.Privilege
;
18
import
com.cloudera.impala.catalog.Db
;
19
import
com.cloudera.impala.common.AnalysisException
;
20
import
com.cloudera.impala.thrift.TDropDbParams;
21
25
public
class
DropDbStmt
extends
StatementBase
{
26
private
final
String
dbName_
;
27
private
final
boolean
ifExists_
;
28
33
public
DropDbStmt
(String dbName,
boolean
ifExists) {
34
this.dbName_ = dbName;
35
this.ifExists_ = ifExists;
36
}
37
38
public
String
getDb
() {
return
dbName_
; }
39
public
boolean
getIfExists
() {
return
ifExists_
; }
40
41
@Override
42
public
String
toSql
() {
43
StringBuilder sb =
new
StringBuilder(
"DROP DATABASE"
);
44
if
(
ifExists_
) {
45
sb.append(
" IF EXISTS "
);
46
}
47
sb.append(
getDb
());
48
return
sb.toString();
49
}
50
51
public
TDropDbParams
toThrift
() {
52
TDropDbParams params =
new
TDropDbParams();
53
params.setDb(
getDb
());
54
params.setIf_exists(
getIfExists
());
55
return
params;
56
}
57
58
@Override
59
public
void
analyze
(
Analyzer
analyzer)
throws
AnalysisException
{
60
Db
db = analyzer.getDb(
dbName_
,
Privilege.DROP
,
false
);
61
if
(db == null && !
ifExists_
) {
62
throw
new
AnalysisException
(
Analyzer
.
DB_DOES_NOT_EXIST_ERROR_MSG
+ dbName_);
63
}
64
65
if
(analyzer.getDefaultDb().toLowerCase().equals(dbName_.toLowerCase())) {
66
throw
new
AnalysisException
(
"Cannot drop current default database: "
+ dbName_);
67
}
68
if
(db != null && db.
numFunctions
() > 0) {
69
throw
new
AnalysisException
(
"Cannot drop non-empty database: "
+ dbName_);
70
}
71
}
72
}
com.cloudera.impala.analysis.DropDbStmt.dbName_
final String dbName_
Definition:
DropDbStmt.java:26
com.cloudera.impala.analysis.DropDbStmt.DropDbStmt
DropDbStmt(String dbName, boolean ifExists)
Definition:
DropDbStmt.java:33
com.cloudera.impala.analysis.DropDbStmt.ifExists_
final boolean ifExists_
Definition:
DropDbStmt.java:27
com.cloudera.impala.analysis.DropDbStmt.toThrift
TDropDbParams toThrift()
Definition:
DropDbStmt.java:51
com.cloudera.impala.catalog.Db.numFunctions
int numFunctions()
Definition:
Db.java:122
com.cloudera.impala.common.AnalysisException
Definition:
AnalysisException.java:21
com.cloudera.impala.analysis.StatementBase
Definition:
StatementBase.java:22
com.cloudera.impala.analysis.DropDbStmt.getDb
String getDb()
Definition:
DropDbStmt.java:38
com.cloudera.impala.analysis.DropDbStmt.toSql
String toSql()
Definition:
DropDbStmt.java:42
com.cloudera.impala.authorization.Privilege
Definition:
Privilege.java:24
com.cloudera.impala.analysis.DropDbStmt.analyze
void analyze(Analyzer analyzer)
Definition:
DropDbStmt.java:59
com.cloudera.impala.analysis.Analyzer
Definition:
Analyzer.java:105
com.cloudera.impala.analysis.Analyzer.DB_DOES_NOT_EXIST_ERROR_MSG
static final String DB_DOES_NOT_EXIST_ERROR_MSG
Definition:
Analyzer.java:107
com.cloudera.impala.analysis.DropDbStmt
Definition:
DropDbStmt.java:25
com.cloudera.impala.analysis.DropDbStmt.getIfExists
boolean getIfExists()
Definition:
DropDbStmt.java:39
com.cloudera.impala.authorization.Privilege.DROP
DROP
Definition:
Privilege.java:27
com.cloudera.impala.catalog.Db
Definition:
Db.java:44
fe
src
main
java
com
cloudera
impala
analysis
DropDbStmt.java
Generated on Thu May 7 2015 16:10:38 for Impala by
1.8.6