Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
JoinOperator.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.thrift.TJoinOp;
18 
19 public enum JoinOperator {
20  INNER_JOIN("INNER JOIN", TJoinOp.INNER_JOIN),
21  LEFT_OUTER_JOIN("LEFT OUTER JOIN", TJoinOp.LEFT_OUTER_JOIN),
22  LEFT_SEMI_JOIN("LEFT SEMI JOIN", TJoinOp.LEFT_SEMI_JOIN),
23  LEFT_ANTI_JOIN("LEFT ANTI JOIN", TJoinOp.LEFT_ANTI_JOIN),
24  RIGHT_OUTER_JOIN("RIGHT OUTER JOIN", TJoinOp.RIGHT_OUTER_JOIN),
25  RIGHT_SEMI_JOIN("RIGHT SEMI JOIN", TJoinOp.RIGHT_SEMI_JOIN),
26  RIGHT_ANTI_JOIN("RIGHT ANTI JOIN", TJoinOp.RIGHT_ANTI_JOIN),
27  FULL_OUTER_JOIN("FULL OUTER JOIN", TJoinOp.FULL_OUTER_JOIN),
28  CROSS_JOIN("CROSS JOIN", TJoinOp.CROSS_JOIN),
29  // Variant of the LEFT ANTI JOIN that is used for the rewrite of
30  // NOT IN subqueries. It can have a single equality join conjunct
31  // that returns TRUE when the rhs is NULL.
32  NULL_AWARE_LEFT_ANTI_JOIN("NULL AWARE LEFT ANTI JOIN",
33  TJoinOp.NULL_AWARE_LEFT_ANTI_JOIN);
34 
35  private final String description_;
36  private final TJoinOp thriftJoinOp_;
37 
38  private JoinOperator(String description, TJoinOp thriftJoinOp) {
39  this.description_ = description;
40  this.thriftJoinOp_ = thriftJoinOp;
41  }
42 
43  @Override
44  public String toString() {
45  return description_;
46  }
47 
48  public TJoinOp toThrift() {
49  return thriftJoinOp_;
50  }
51 
52  public boolean isInnerJoin() {
53  return this == INNER_JOIN;
54  }
55 
56  public boolean isOuterJoin() {
57  return this == LEFT_OUTER_JOIN
58  || this == RIGHT_OUTER_JOIN
59  || this == FULL_OUTER_JOIN;
60  }
61 
62  public boolean isSemiJoin() {
63  return this == JoinOperator.LEFT_SEMI_JOIN || this == JoinOperator.LEFT_ANTI_JOIN ||
64  this == JoinOperator.RIGHT_SEMI_JOIN || this == JoinOperator.RIGHT_ANTI_JOIN ||
66  }
67 
68  public boolean isLeftSemiJoin() {
69  return this == JoinOperator.LEFT_SEMI_JOIN || this == JoinOperator.LEFT_ANTI_JOIN ||
71  }
72 
73  public boolean isRightSemiJoin() {
74  return this == JoinOperator.RIGHT_SEMI_JOIN || this == JoinOperator.RIGHT_ANTI_JOIN;
75  }
76 
77  public boolean isCrossJoin() {
78  return this == JoinOperator.CROSS_JOIN;
79  }
80 
81  public boolean isFullOuterJoin() {
82  return this == JoinOperator.FULL_OUTER_JOIN;
83  }
84 
85  public boolean isNullAwareLeftAntiJoin() {
87  }
88 
89  public boolean isAntiJoin() {
90  return this == JoinOperator.LEFT_ANTI_JOIN || this == JoinOperator.RIGHT_ANTI_JOIN ||
92  }
93 
94  public JoinOperator invert() {
95  switch (this) {
96  case LEFT_OUTER_JOIN: return RIGHT_OUTER_JOIN;
97  case RIGHT_OUTER_JOIN: return LEFT_OUTER_JOIN;
98  case LEFT_SEMI_JOIN: return RIGHT_SEMI_JOIN;
99  case RIGHT_SEMI_JOIN: return LEFT_SEMI_JOIN;
100  case LEFT_ANTI_JOIN: return RIGHT_ANTI_JOIN;
101  case RIGHT_ANTI_JOIN: return LEFT_ANTI_JOIN;
102  case NULL_AWARE_LEFT_ANTI_JOIN: throw new IllegalStateException("Not implemented");
103  default: return this;
104  }
105  }
106 }
JoinOperator(String description, TJoinOp thriftJoinOp)