Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
CollectionTableRef.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.google.common.base.Preconditions;
19 
24 public class CollectionTableRef extends TableRef {
25  // Expr that returns the referenced collection. Typically a SlotRef into the
26  // parent scan's tuple. Result of analysis. Fully resolved against base tables.
28 
34  public CollectionTableRef(TableRef tableRef, Path resolvedPath) {
35  super(tableRef);
36  resolvedPath_ = resolvedPath;
37  // Use the last path element as an implicit alias if no explicit alias was given.
38  if (hasExplicitAlias()) return;
39  String implicitAlias = rawPath_.get(rawPath_.size() - 1).toLowerCase();
40  aliases_ = new String[] { implicitAlias };
41  }
42 
47  super(other);
49  (other.collectionExpr_ != null) ? other.collectionExpr_.clone() : null;
50  }
51 
52  @Override
53  public void analyze(Analyzer analyzer) throws AnalysisException {
54  Preconditions.checkNotNull(getPrivilegeRequirement());
55  desc_ = analyzer.registerTableRef(this);
56  if (resolvedPath_.getRootDesc() != null) {
57  SlotDescriptor parentSlotDesc = analyzer.registerSlotRef(resolvedPath_);
58  collectionExpr_ = new SlotRef(parentSlotDesc);
59  // Must always be materialized to ensure the correct cardinality after unnesting.
60  analyzer.materializeSlots(collectionExpr_);
61  }
62  isAnalyzed_ = true;
63  analyzeJoin(analyzer);
64  }
65 
66  @Override
67  public boolean isChildRef() {
68  Preconditions.checkNotNull(resolvedPath_);
69  return resolvedPath_.getRootDesc() != null;
70  }
71 
72  public Expr getCollectionExpr() { return collectionExpr_; }
73 
74  @Override
75  public TableRef clone() { return new CollectionTableRef(this); }
76 }
CollectionTableRef(TableRef tableRef, Path resolvedPath)
void analyzeJoin(Analyzer analyzer)
Definition: TableRef.java:339
TupleDescriptor getRootDesc()
Definition: Path.java:239