Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
com.cloudera.impala.analysis.Path Class Reference
Collaboration diagram for com.cloudera.impala.analysis.Path:

Classes

enum  PathType
 

Public Member Functions

 Path (TupleDescriptor rootDesc, List< String > rawPath)
 
 Path (Table rootTable, List< String > rawPath)
 
 Path (Path rootPath, List< String > relRawPath)
 
boolean resolve ()
 
Table getRootTable ()
 
TupleDescriptor getRootDesc ()
 
List< String > getRawPath ()
 
boolean isResolved ()
 
List< TypegetMatchedTypes ()
 
List< Integer > getMatchedPositions ()
 
boolean hasNonDestCollection ()
 
String getFirstCollectionName ()
 
Type getFirstCollectionType ()
 
Type destType ()
 
Table destTable ()
 
Column destColumn ()
 
TupleDescriptor destTupleDesc ()
 
List< String > getFullyQualifiedRawPath ()
 
List< Integer > getAbsolutePath ()
 
String toString ()
 

Static Public Member Functions

static StructType getTypeAsStruct (Type t)
 
static ArrayList< String > createRawPath (String rootAlias, String fieldName)
 
static Path createRelPath (Path rootPath, String...fieldNames)
 

Static Public Attributes

static final String ARRAY_ITEM_FIELD_NAME = "item"
 
static final String ARRAY_POS_FIELD_NAME = "pos"
 
static final String MAP_KEY_FIELD_NAME = "key"
 
static final String MAP_VALUE_FIELD_NAME = "value"
 

Private Attributes

final List< String > rawPath_
 
final TupleDescriptor rootDesc_
 
final Table rootTable_
 
final Path rootPath_
 
final List< TypematchedTypes_ = Lists.newArrayList()
 
final List< Integer > matchedPositions_ = Lists.newArrayList()
 
int firstCollectionPathIdx_ = -1
 
int firstCollectionTypeIdx_ = -1
 
boolean isResolved_ = false
 
List< Integer > absolutePath_ = null
 

Detailed Description

Represents a resolved or unresolved dot-separated path that is rooted at a registered tuple descriptor, catalog table/view, or an existing resolved path.

This class implements the resolution logic for mapping an implicit or explicit raw path to the corresponding physical types/positions in the schema tree.

Implicit vs. Explicit Paths The item of an array and the key/value of maps are accessed via their implicit field names. However, if the type of an array item or a map value is a struct, then we allow omitting the explicit reference to the struct type in paths for accessing fields within that struct as a shorthand for user convenience. An explicit reference to the struct type is always legal. Paths that explicitly reference such a struct are "physical" because they typically map exactly to the schema representation in the underlying storage format (e.g. Parquet/Avro). Paths that omit the struct reference are called "implicit". During resolution, explicit paths are always preferred over implicit paths for resolving ambiguities.

Example create table d.t ( c array<struct<f:int,item:int,pos:int>> );

select ... from d.t.c d.t.c <– resolves to type array<struct<f:int,item:int,pos:int>> c alias <– type struct<item:struct<f:int,item:int,pos:int>,pos:bigint>>

select c.item.f, c.f from d.t.c c.item.f <– explicit path to "f" c.f <– implicit path to "f", skips "item" reference (same for the unqualified versions item.f and f)

select c.item, c.item.item from d.t.c c.item <– explicit path to "item" struct of type struct<f:int,item:string> c.item.item <– explicit path to string "item"; there is no logical path to the string "item" due to the "item" name conflict c.pos <– explicit path to "pos" of type bigint c.item.pos <– explicit path to "pos" of type int; there is no logical path to the int "pos" due to the "pos" name conflict (same for unqualified versions item, item.item, pos, item.pos)

Please refer to TestImplicitAndExplicitPaths() for analogous examples for maps.

Definition at line 74 of file Path.java.

Constructor & Destructor Documentation

com.cloudera.impala.analysis.Path.Path ( TupleDescriptor  rootDesc,
List< String >  rawPath 
)
inline
com.cloudera.impala.analysis.Path.Path ( Table  rootTable,
List< String >  rawPath 
)
inline
com.cloudera.impala.analysis.Path.Path ( Path  rootPath,
List< String >  relRawPath 
)
inline

Member Function Documentation

static ArrayList<String> com.cloudera.impala.analysis.Path.createRawPath ( String  rootAlias,
String  fieldName 
)
inlinestatic

Returns a raw path from a known root alias and field name.

Definition at line 350 of file Path.java.

Referenced by com.cloudera.impala.analysis.TableRef.analyzeJoin().

static Path com.cloudera.impala.analysis.Path.createRelPath ( Path  rootPath,
String...  fieldNames 
)
inlinestatic

Definition at line 356 of file Path.java.

References com.cloudera.impala.analysis.Path.Path().

Column com.cloudera.impala.analysis.Path.destColumn ( )
inline

Returns the destination Column of this path, or null if the destination of this path is not a Column. This path must be rooted at a table or a tuple descriptor corresponding to a table for the destination to be a Column.

Definition at line 292 of file Path.java.

References com.cloudera.impala.analysis.Path.isResolved_, com.cloudera.impala.analysis.Path.rawPath_, and com.cloudera.impala.analysis.Path.rootTable_.

TupleDescriptor com.cloudera.impala.analysis.Path.destTupleDesc ( )
inline

Returns the destination tuple descriptor of this path, or null if the destination of this path is not a registered alias.

Definition at line 302 of file Path.java.

References com.cloudera.impala.analysis.Path.isResolved_, com.cloudera.impala.analysis.Path.matchedTypes_, and com.cloudera.impala.analysis.Path.rootDesc_.

List<Integer> com.cloudera.impala.analysis.Path.getAbsolutePath ( )
inline

Returns the absolute physical path in positions starting from the schema root to the destination of this path.

Definition at line 325 of file Path.java.

References com.cloudera.impala.analysis.Path.absolutePath_, com.cloudera.impala.analysis.Path.isResolved_, com.cloudera.impala.analysis.Path.matchedPositions_, and com.cloudera.impala.analysis.Path.rootDesc_.

String com.cloudera.impala.analysis.Path.getFirstCollectionName ( )
inline
Type com.cloudera.impala.analysis.Path.getFirstCollectionType ( )
inline
List<String> com.cloudera.impala.analysis.Path.getFullyQualifiedRawPath ( )
inline
List<Integer> com.cloudera.impala.analysis.Path.getMatchedPositions ( )
inline
List<Type> com.cloudera.impala.analysis.Path.getMatchedTypes ( )
inline
List<String> com.cloudera.impala.analysis.Path.getRawPath ( )
inline
TupleDescriptor com.cloudera.impala.analysis.Path.getRootDesc ( )
inline
Table com.cloudera.impala.analysis.Path.getRootTable ( )
inline
static StructType com.cloudera.impala.analysis.Path.getTypeAsStruct ( Type  t)
inlinestatic

If the given type is a collection, returns a collection struct type representing named fields of its explicit path. Returns the given type itself if it is already a struct. Requires that the given type is a complex type.

Definition at line 227 of file Path.java.

References com.cloudera.impala.catalog.Type.isArrayType(), and com.cloudera.impala.catalog.Type.isStructType().

Referenced by com.cloudera.impala.analysis.Path.resolve().

boolean com.cloudera.impala.analysis.Path.hasNonDestCollection ( )
inline
boolean com.cloudera.impala.analysis.Path.isResolved ( )
inline

Definition at line 241 of file Path.java.

References com.cloudera.impala.analysis.Path.isResolved_.

boolean com.cloudera.impala.analysis.Path.resolve ( )
inline

Member Data Documentation

List<Integer> com.cloudera.impala.analysis.Path.absolutePath_ = null
private

Definition at line 117 of file Path.java.

Referenced by com.cloudera.impala.analysis.Path.getAbsolutePath().

int com.cloudera.impala.analysis.Path.firstCollectionTypeIdx_ = -1
private
final List<Integer> com.cloudera.impala.analysis.Path.matchedPositions_ = Lists.newArrayList()
private
final List<Type> com.cloudera.impala.analysis.Path.matchedTypes_ = Lists.newArrayList()
private
final Path com.cloudera.impala.analysis.Path.rootPath_
private

The documentation for this class was generated from the following file: