Package org.apache.drill.exec.ops
Class ViewExpansionContext
java.lang.Object
org.apache.drill.exec.ops.ViewExpansionContext
Contains context information about view expansion(s) in a query. Part of
.QueryContext
. Before expanding a view into its definition, as part of the
DrillViewTable.toRel(org.apache.calcite.plan.RelOptTable.ToRelContext, org.apache.calcite.plan.RelOptTable)
, first a ViewExpansionContext.ViewExpansionToken
is requested from ViewExpansionContext
through reserveViewExpansionToken(String)
.
Once view expansion is complete, a token is released through ViewExpansionContext.ViewExpansionToken.release()
. A view definition
itself may contain zero or more views for expanding those nested views also a token is obtained.
Ex:
Following are the available view tables: { "view_1", "view_2", "view_3", "view_4" }. Corresponding owners are
{"view1Owner", "view2Owner", "view3Owner", "view4Owner"}.
Definition of "view4" : "SELECT field4 FROM view3"
Definition of "view3" : "SELECT field4, field3 FROM view2"
Definition of "view2" : "SELECT field4, field3, field2 FROM view1"
Definition of "view1" : "SELECT field4, field3, field2, field1 FROM someTable"
Query is: "SELECT * FROM view4".
Steps:
1. "view4" comes for expanding it into its definition
2. A token "view4Token" is requested through reserveViewExpansionToken(String view4Owner)
3. "view4" is called for expansion. As part of it
3.1 "view3" comes for expansion
3.2 A token "view3Token" is requested through reserveViewExpansionToken(String view3Owner)
3.3 "view3" is called for expansion. As part of it
3.3.1 "view2" comes for expansion
3.3.2 A token "view2Token" is requested through reserveViewExpansionToken(String view2Owner)
3.3.3 "view2" is called for expansion. As part of it
3.3.3.1 "view1" comes for expansion
3.3.3.2 A token "view1Token" is requested through reserveViewExpansionToken(String view1Owner)
3.3.3.3 "view1" is called for expansion
3.3.3.4 "view1" expansion is complete
3.3.3.5 Token "view1Token" is released
3.3.4 "view2" expansion is complete
3.3.5 Token "view2Token" is released
3.4 "view3" expansion is complete
3.5 Token "view3Token" is released
4. "view4" expansion is complete
5. Token "view4Token" is released.-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Represents token issued to a view owner for expanding the view. -
Constructor Summary
ConstructorDescriptionViewExpansionContext
(DrillConfig config, SchemaConfig.SchemaConfigInfoProvider schemaConfigInfoProvider) ViewExpansionContext
(QueryContext queryContext) -
Method Summary
Modifier and TypeMethodDescriptionboolean
reserveViewExpansionToken
(String viewOwner) Reserve a token for expansion of view owned by given user name.void
setViewExpander
(DrillViewExpander viewExpander)
-
Constructor Details
-
ViewExpansionContext
-
ViewExpansionContext
public ViewExpansionContext(DrillConfig config, SchemaConfig.SchemaConfigInfoProvider schemaConfigInfoProvider)
-
-
Method Details
-
isImpersonationEnabled
public boolean isImpersonationEnabled() -
reserveViewExpansionToken
Reserve a token for expansion of view owned by given user name. If it can't issue any more tokens, throwsUserException
.- Parameters:
viewOwner
- Name of the user who owns the view.- Returns:
- An instance of
ViewExpansionContext.ViewExpansionToken
which must be released when done using the token.
-
setViewExpander
-
getViewExpander
-