org.makumba.providers.query.mql
Class MqlQueryAnalysis

java.lang.Object
  extended by org.makumba.providers.query.mql.MqlQueryAnalysis
All Implemented Interfaces:
QueryAnalysis

public class MqlQueryAnalysis
extends Object
implements QueryAnalysis

The hearth of the MQL query analysis and compilation. The query is first pre-processed and then the initial parsing takes place to produce the initial mql tree. After this, the tree is transformed by the MqlSqlWalker for analysis and finally transformed again for sql query generation.

Version:
$Id: MqlQueryAnalysis.java,v 1.1 Apr 29, 2009 8:54:20 PM manu Exp $
Author:
Cristian Bogdan, Manuel Gay

Nested Class Summary
static class MqlQueryAnalysis.ParamConstant
           
 
Field Summary
protected  Vector<String> generatedLabels
           
protected  DataDefinition insertIn
           
static String MAKUMBA_PARAM
           
 
Constructor Summary
MqlQueryAnalysis(antlr.collections.AST pass1, DataDefinition knownLabels)
          constructs a query analysis given the pass1 AST tree and a set of known labels (used for MDD function parameters)
MqlQueryAnalysis(String queryAndInsert, boolean optimizeJoins, boolean autoLeftJoin)
           
 
Method Summary
 String createLabel()
           
(package private) static String formatQueryAndInsert(String query, String insertIn)
           
 antlr.ASTFactory getAnalyserFactory()
           
 antlr.collections.AST getAnalyserTree()
           
 Map<String,Object> getConstantValues()
           
 String getFieldOfExpr(String expr)
           
 DataDefinition getLabelType(String labelName)
          Gets the type of a label used within the query FIXME: remove, inline everywhere as getLabelTypes().get(labelName) for that to work, OQL and MQL need to put their aliases also in the Map returned by getLabelTypes() HQL does not support aliases in the first place
 Map<String,DataDefinition> getLabelTypes()
          Gets the type of the fields between FROM and WHERE
 boolean getNoFrom()
           
 List<String> getParameterOrder()
           
 DataDefinition getParameterTypes()
          Gets the types of the query parameters, as resulted from the query analysis.
 antlr.collections.AST getPass1Tree()
          return the pass1 (syntax) AST tree
 DataDefinition getProjectionType()
          Gets the type of the fields between SELECT and FROM
 String getQuery()
          Gets the original query that is analyzed by this object
 DataDefinition getTypeOfExprField(String expr)
           
 Collection<String> getWarnings()
          Get the warnings resulted from query analysis
(package private) static boolean isNil(antlr.collections.AST a)
           
(package private) static void setNullTest(antlr.collections.AST a)
           
static String showAst(antlr.collections.AST ast)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAKUMBA_PARAM

public static final String MAKUMBA_PARAM
See Also:
Constant Field Values

insertIn

protected DataDefinition insertIn

generatedLabels

protected Vector<String> generatedLabels
Constructor Detail

MqlQueryAnalysis

public MqlQueryAnalysis(antlr.collections.AST pass1,
                        DataDefinition knownLabels)
constructs a query analysis given the pass1 AST tree and a set of known labels (used for MDD function parameters)

Parameters:
pass1 - the pass1 tree
knownLabels - the known labels

MqlQueryAnalysis

MqlQueryAnalysis(String queryAndInsert,
                 boolean optimizeJoins,
                 boolean autoLeftJoin)
Method Detail

formatQueryAndInsert

static String formatQueryAndInsert(String query,
                                   String insertIn)

getQuery

public String getQuery()
Description copied from interface: QueryAnalysis
Gets the original query that is analyzed by this object

Specified by:
getQuery in interface QueryAnalysis

getLabelType

public DataDefinition getLabelType(String labelName)
Description copied from interface: QueryAnalysis
Gets the type of a label used within the query FIXME: remove, inline everywhere as getLabelTypes().get(labelName) for that to work, OQL and MQL need to put their aliases also in the Map returned by getLabelTypes() HQL does not support aliases in the first place

Specified by:
getLabelType in interface QueryAnalysis
Parameters:
labelName - the name of the label
Returns:
The type of the label as declared in the FROM part of the query

getLabelTypes

public Map<String,DataDefinition> getLabelTypes()
Description copied from interface: QueryAnalysis
Gets the type of the fields between FROM and WHERE

Specified by:
getLabelTypes in interface QueryAnalysis
Returns:
A DataDefinition containing in the first field the type and name of the first label, the second field the type and name of the second label $2 etc.

getParameterTypes

public DataDefinition getParameterTypes()
Description copied from interface: QueryAnalysis
Gets the types of the query parameters, as resulted from the query analysis.

Specified by:
getParameterTypes in interface QueryAnalysis
Returns:
A DataDefinition containing in the first field the type of the QL parameter mentioned first in the query. Each mentioning of a parameter new will get a new field in this DataDefinition!

getProjectionType

public DataDefinition getProjectionType()
Description copied from interface: QueryAnalysis
Gets the type of the fields between SELECT and FROM

Specified by:
getProjectionType in interface QueryAnalysis
Returns:
A DataDefinition containing in the first field the type and name of the first QL projection, the second field the type and name of the second QL projection $2 etc.

getFieldOfExpr

public String getFieldOfExpr(String expr)

getTypeOfExprField

public DataDefinition getTypeOfExprField(String expr)

showAst

public static String showAst(antlr.collections.AST ast)

isNil

static boolean isNil(antlr.collections.AST a)

setNullTest

static void setNullTest(antlr.collections.AST a)

createLabel

public String createLabel()

getAnalyserTree

public antlr.collections.AST getAnalyserTree()

getAnalyserFactory

public antlr.ASTFactory getAnalyserFactory()

getNoFrom

public boolean getNoFrom()

getParameterOrder

public List<String> getParameterOrder()

getConstantValues

public Map<String,Object> getConstantValues()

getPass1Tree

public antlr.collections.AST getPass1Tree()
Description copied from interface: QueryAnalysis
return the pass1 (syntax) AST tree

Specified by:
getPass1Tree in interface QueryAnalysis
Returns:

getWarnings

public Collection<String> getWarnings()
Description copied from interface: QueryAnalysis
Get the warnings resulted from query analysis

Specified by:
getWarnings in interface QueryAnalysis
Returns:
a collection of warnings, as strings