Class GridSqlQueryParser
- java.lang.Object
-
- org.apache.ignite.internal.processors.query.h2.sql.GridSqlQueryParser
-
public class GridSqlQueryParser extends Object
H2 Query parser.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGridSqlQueryParser.Getter<T,R>Field getter.static classGridSqlQueryParser.PreparedWithRemaining
-
Field Summary
Fields Modifier and Type Field Description static StringORG_H2_COMMAND_COMMAND_LISTstatic StringPARAM_DATA_REGIONData region name.static StringPARAM_WRAP_VALUEstatic GridSqlQueryParser.Getter<org.h2.table.TableView,org.h2.command.dml.Query>VIEW_QUERY
-
Constructor Summary
Constructors Constructor Description GridSqlQueryParser(boolean useOptimizedSubqry, IgniteLogger log)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Integer>cacheIds()static booleancheckMultipleStatements(PreparedStatement stmt)static voidcheckTypeSupported(int type, String errMsg)static voidfailIfSelectForUpdateQuery(org.h2.command.Prepared p)GridCacheContextgetFirstPartitionedCache()Get first (i.e. random, as we need any one) partitioned cache from parsed query to determine expected query parallelism.static booleanisDml(org.h2.command.Prepared stmt)Check whether statement is DML statement.static booleanisExplainUpdate(org.h2.command.Prepared statement)Determines if specified prepared statement is an EXPLAIN of update operation: UPDATE, DELETE, etc.booleanisLocalQuery()Check if query may be run locally on all caches mentioned in the query.static booleanisStreamableInsertStatement(org.h2.command.Prepared prep)Check if passed statement is insert statement eligible for streaming.GridSqlStatementparse(org.h2.command.Prepared stmt)static GridSqlQueryparseQuery(org.h2.command.Prepared prepared, boolean useOptimizedSubqry, IgniteLogger log)Parse query.static org.h2.command.Preparedprepared(PreparedStatement stmt)static GridSqlQueryParser.PreparedWithRemainingpreparedWithRemaining(PreparedStatement stmt)static org.h2.command.dml.Queryquery(org.h2.command.Prepared qry)List<GridH2Table>tablesForDml()Extract all tables participating in DML statement.
-
-
-
Field Detail
-
VIEW_QUERY
public static final GridSqlQueryParser.Getter<org.h2.table.TableView,org.h2.command.dml.Query> VIEW_QUERY
-
ORG_H2_COMMAND_COMMAND_LIST
public static final String ORG_H2_COMMAND_COMMAND_LIST
- See Also:
- Constant Field Values
-
PARAM_WRAP_VALUE
public static final String PARAM_WRAP_VALUE
- See Also:
- Constant Field Values
-
PARAM_DATA_REGION
public static final String PARAM_DATA_REGION
Data region name.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GridSqlQueryParser
public GridSqlQueryParser(boolean useOptimizedSubqry, IgniteLogger log)- Parameters:
useOptimizedSubqry- If we have to find correct order for table filters in FROM clause. Relies on uniqueness of table filter aliases.log- Logger.
-
-
Method Detail
-
checkMultipleStatements
public static boolean checkMultipleStatements(PreparedStatement stmt)
- Parameters:
stmt- Prepared statement to check.- Returns:
truein case of multiple statements.
-
prepared
public static org.h2.command.Prepared prepared(PreparedStatement stmt)
- Parameters:
stmt- Prepared statement.- Returns:
- Parsed select.
-
preparedWithRemaining
public static GridSqlQueryParser.PreparedWithRemaining preparedWithRemaining(PreparedStatement stmt)
- Parameters:
stmt- Prepared statement.- Returns:
- Parsed select.
-
failIfSelectForUpdateQuery
public static void failIfSelectForUpdateQuery(org.h2.command.Prepared p)
- Parameters:
p- Prepared.
-
query
public static org.h2.command.dml.Query query(org.h2.command.Prepared qry)
- Parameters:
qry- Prepared.- Returns:
- Query.
-
isDml
public static boolean isDml(org.h2.command.Prepared stmt)
Check whether statement is DML statement.- Parameters:
stmt- Statement.- Returns:
Trueif this is DML.
-
isLocalQuery
public boolean isLocalQuery()
Check if query may be run locally on all caches mentioned in the query.- Returns:
trueif query may be run locally on all caches mentioned in the query, i.e. there's no need to run distributed query.
-
getFirstPartitionedCache
public GridCacheContext getFirstPartitionedCache()
Get first (i.e. random, as we need any one) partitioned cache from parsed query to determine expected query parallelism.- Returns:
- Context for the first of partitioned caches mentioned in the query,
or
nullif it does not involve partitioned caches.
-
tablesForDml
public List<GridH2Table> tablesForDml() throws IgniteSQLException
Extract all tables participating in DML statement.- Returns:
- List of tables participate at query.
- Throws:
IgniteSQLException- in case query contains virtual tables.
-
parseQuery
public static GridSqlQuery parseQuery(org.h2.command.Prepared prepared, boolean useOptimizedSubqry, IgniteLogger log)
Parse query.- Parameters:
prepared- Prepared statement.useOptimizedSubqry- Whether to user optimized subquery.- Returns:
- Parsed query.
-
parse
public final GridSqlStatement parse(org.h2.command.Prepared stmt)
- Parameters:
stmt- Prepared statement.- Returns:
- Parsed AST.
-
isStreamableInsertStatement
public static boolean isStreamableInsertStatement(org.h2.command.Prepared prep)
Check if passed statement is insert statement eligible for streaming.- Parameters:
prep- Prepared statement.- Returns:
Trueif streamable insert.
-
isExplainUpdate
public static boolean isExplainUpdate(org.h2.command.Prepared statement)
Determines if specified prepared statement is an EXPLAIN of update operation: UPDATE, DELETE, etc. (e.g. not a SELECT query).- Parameters:
statement- statement to probe.- Returns:
Trueif statement is EXPLAIN UPDATE, EXPLAIN DELETE or etc.;falseotherwise.
-
checkTypeSupported
public static void checkTypeSupported(int type, String errMsg)
-
-