net.sf.farrago.session
Interface FarragoSessionPreparingStmt

All Superinterfaces:
ClosableAllocation, FarragoAllocation
All Known Implementing Classes:
FarragoPreparingStmt, LucidDbPreparingStmt

public interface FarragoSessionPreparingStmt
extends FarragoAllocation

FarragoSessionPreparingStmt represents the process of Farrago-specific preparation of a single SQL statement (it's not a context for executing a series of statements; for that, see FarragoSessionStmtContext). The result is a FarragoSessionExecutableStmt.

FarragoSessionPreparingStmt has a fleeting lifetime, which is why its name is in the progressive tense. Once its job is done, it should be discarded (and can't be reused).

Version:
$Id: //open/dev/farrago/src/net/sf/farrago/session/FarragoSessionPreparingStmt.java#21 $
Author:
John V. Sichi

Method Summary
 void analyzeSql(SqlNode sqlNode, FarragoSessionAnalyzedSql analyzedSql)
          Analyzes an SQL expression, and returns information about it.
 void disableStatementCaching()
          Disables caching for the statement
 FarragoTypeFactory getFarragoTypeFactory()
           
 FennelDbHandle getFennelDbHandle()
           
 FarragoSessionIndexMap getIndexMap()
           
 JavaRelImplementor getRelImplementor(RexBuilder rexBuilder)
          Obtains an implementor for relational expressions.
 RelOptCluster getRelOptCluster()
           
 FarragoRepos getRepos()
           
 FarragoSessionStmtContext getRootStmtContext()
           
 FarragoSession getSession()
           
 String getSql()
           
 SqlOperatorTable getSqlOperatorTable()
           
 SqlToRelConverter getSqlToRelConverter()
           
 SqlValidator getSqlValidator()
           
 FarragoSessionStmtValidator getStmtValidator()
           
 FarragoSessionExecutableStmt implement(RelNode rootRel, SqlKind sqlKind, boolean logical)
          Implements a logical or physical query plan but does not execute it.
 RelOptTable loadColumnSet(SqlIdentifier name)
          Looks up a named ColumnSet and loads its optimizer representation.
 boolean mayCacheImplementation()
          Test if the implementation may be saved for reuse.
 void postValidate(SqlNode validatedSqlNode)
          Performs post-validation work after SqlValidator has been called.
 void preImplement()
          Sets up the environment the FarragoPreparingStmt needs in order to implement (i.e.
 FarragoSessionExecutableStmt prepare(SqlNode sqlNode, SqlNode sqlNodeOriginal)
          Prepares (translates and implements) a parsed query or DML statement, but does not execute it.
 
Methods inherited from interface org.eigenbase.util.ClosableAllocation
closeAllocation
 

Method Detail

prepare

FarragoSessionExecutableStmt prepare(SqlNode sqlNode,
                                     SqlNode sqlNodeOriginal)
Prepares (translates and implements) a parsed query or DML statement, but does not execute it.

Parameters:
sqlNode - top-level node of parsed statement
sqlNodeOriginal - original form of sqlNode if it has been rewritten by validation; otherwise, same as sqlNode
Returns:
prepared FarragoSessionExecutableStmt

analyzeSql

void analyzeSql(SqlNode sqlNode,
                FarragoSessionAnalyzedSql analyzedSql)
Analyzes an SQL expression, and returns information about it. Used when an expression is not going to be executed directly, but needs to be validated as part of the definition of some containing object such as a view.

Parameters:
sqlNode - SQL expression to be analyzed
analyzedSql - receives analysis result

preImplement

void preImplement()
Sets up the environment the FarragoPreparingStmt needs in order to implement (i.e. to generate code). When preparing a parsed query (by calling prepare(org.eigenbase.sql.SqlNode, org.eigenbase.sql.SqlNode)) this happens automatically. But when implementing a query presented as a query plan (by calling implement(org.eigenbase.rel.RelNode, org.eigenbase.sql.SqlKind, boolean)), you must call this method first, even before constructing the query plan.


postValidate

void postValidate(SqlNode validatedSqlNode)
Performs post-validation work after SqlValidator has been called.

Parameters:
validatedSqlNode - output of SqlValidator

implement

FarragoSessionExecutableStmt implement(RelNode rootRel,
                                       SqlKind sqlKind,
                                       boolean logical)
Implements a logical or physical query plan but does not execute it. You must call preImplement() first, in fact before constructing the query plan.

Parameters:
rootRel - root of query plan (relational expression)
sqlKind - SqlKind for the relational expression: only SqlKind.Explain and SqlKind.Dml are special cases.
logical - true for a logical query plan (still needs to be optimized), false for a physical plan.
Returns:
prepared FarragoSessionExecutableStmt

mayCacheImplementation

boolean mayCacheImplementation()
Test if the implementation may be saved for reuse. Called after the statement has been prepared.


disableStatementCaching

void disableStatementCaching()
Disables caching for the statement


getStmtValidator

FarragoSessionStmtValidator getStmtValidator()
Returns:
generic stmt validator

getSqlOperatorTable

SqlOperatorTable getSqlOperatorTable()
Returns:
the SqlOperatorTable used for operator lookup during this stmt's preparation; this includes both system-defined and user-defined functions

getSqlValidator

SqlValidator getSqlValidator()
Returns:
the SqlValidator for this statement (creating it if it does not yet exist)

getSqlToRelConverter

SqlToRelConverter getSqlToRelConverter()
Returns:
the SqlToRelConverter used by this stmt (creating it if it does not yet exist)

getRelOptCluster

RelOptCluster getRelOptCluster()
Returns:
the RelOptCluster used by this stmt (possibly creating the SqlToRelConverter as a side effect if it does not yet exist).

getRepos

FarragoRepos getRepos()
Returns:
repos for this stmt

getFennelDbHandle

FennelDbHandle getFennelDbHandle()
Returns:
handle to Fennel database accessed by this stmt

getFarragoTypeFactory

FarragoTypeFactory getFarragoTypeFactory()
Returns:
type factory for this stmt

getIndexMap

FarragoSessionIndexMap getIndexMap()
Returns:
FarragoSessionIndexMap to use for accessing index storage

getSession

FarragoSession getSession()
Returns:
session which invoked statement preparation

getSql

String getSql()
Returns:
SQL text of the statement being prepared

getRelImplementor

JavaRelImplementor getRelImplementor(RexBuilder rexBuilder)
Obtains an implementor for relational expressions.

Parameters:
rexBuilder - RexBuilder to use for constructing row expressions
Returns:
new expression implementor

loadColumnSet

RelOptTable loadColumnSet(SqlIdentifier name)
Looks up a named ColumnSet and loads its optimizer representation.

Parameters:
name - name of ColumnSet
Returns:
optimizer representation, or null if not found

getRootStmtContext

FarragoSessionStmtContext getRootStmtContext()
Returns:
the root statement context for this statement