use of org.h2.table.TableView in project ignite by apache.
the class GridSqlQueryParser method parseTable.
/**
* @param tbl Table.
*/
private GridSqlElement parseTable(Table tbl) {
GridSqlElement res = (GridSqlElement) h2ObjToGridObj.get(tbl);
if (res == null) {
// Table here is semantically equivalent to a table filter.
if (tbl instanceof TableBase || tbl instanceof MetaTable)
return new GridSqlTable(tbl);
// different table filters anyways. Thus the semantics will be correct.
if (tbl instanceof TableView) {
if (((TableView) tbl).isRecursive()) {
throw new IgniteSQLException("Recursive CTE ('WITH RECURSIVE (...)') is not supported.", IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
}
Query qry = VIEW_QUERY.get((TableView) tbl);
res = new GridSqlSubquery(parseQuery(qry));
} else if (tbl instanceof FunctionTable)
res = parseExpression(FUNC_EXPR.get((FunctionTable) tbl), false);
else if (tbl instanceof RangeTable) {
res = new GridSqlFunction(GridSqlFunctionType.SYSTEM_RANGE);
res.addChild(parseExpression(RANGE_MIN.get((RangeTable) tbl), false));
res.addChild(parseExpression(RANGE_MAX.get((RangeTable) tbl), false));
} else if (tbl instanceof MetaTable)
res = new GridSqlTable(tbl);
else
assert0(false, "Unexpected Table implementation [cls=" + tbl.getClass().getSimpleName() + ']');
h2ObjToGridObj.put(tbl, res);
}
return res;
}
use of org.h2.table.TableView in project ignite by apache.
the class GridSqlQueryParser method collectOptimizedTableFiltersOrder.
/**
* @param qry Query.
*/
private void collectOptimizedTableFiltersOrder(Query qry) {
if (qry instanceof SelectUnion) {
collectOptimizedTableFiltersOrder(((SelectUnion) qry).getLeft());
collectOptimizedTableFiltersOrder(((SelectUnion) qry).getRight());
} else {
Select select = (Select) qry;
TableFilter filter = select.getTopTableFilter();
int i = 0;
do {
assert0(filter != null, select);
assert0(filter.getNestedJoin() == null, select);
// Here all the table filters must have generated unique aliases,
// thus we can store them in the same map for all the subqueries.
optimizedTableFilterOrder.put(filter.getTableAlias(), i++);
Table tbl = filter.getTable();
// Go down and collect inside of optimized subqueries.
if (tbl instanceof TableView) {
ViewIndex viewIdx = (ViewIndex) filter.getIndex();
collectOptimizedTableFiltersOrder(viewIdx.getQuery());
}
filter = filter.getJoin();
} while (filter != null);
}
}
Aggregations