Search in sources :

Example 76 with GridH2Table

use of org.apache.ignite.internal.processors.query.h2.opt.GridH2Table in project ignite by apache.

the class GridSqlQueryParser method tablesForDml.

/**
 * Extract all tables participating in DML statement.
 *
 * @return List of tables participate at query.
 * @throws IgniteSQLException in case query contains virtual tables.
 */
public List<GridH2Table> tablesForDml() throws IgniteSQLException {
    Collection<?> parserObjects = h2ObjToGridObj.values();
    List<GridH2Table> tbls = new ArrayList<>(parserObjects.size());
    // check all involved caches
    for (Object o : parserObjects) {
        if (o instanceof GridSqlMerge)
            o = ((GridSqlMerge) o).into();
        else if (o instanceof GridSqlInsert)
            o = ((GridSqlInsert) o).into();
        else if (o instanceof GridSqlUpdate)
            o = ((GridSqlUpdate) o).target();
        else if (o instanceof GridSqlDelete)
            o = ((GridSqlDelete) o).from();
        if (o instanceof GridSqlAlias)
            o = GridSqlAlias.unwrap((GridSqlAst) o);
        if (o instanceof GridSqlTable) {
            GridH2Table h2tbl = ((GridSqlTable) o).dataTable();
            if (h2tbl == null) {
                // Check for virtual tables.
                throw new IgniteSQLException("Operation not supported for table '" + ((GridSqlTable) o).tableName() + "'", IgniteQueryErrorCode.UNSUPPORTED_OPERATION);
            }
            tbls.add(h2tbl);
        }
    }
    return tbls;
}
Also used : GridH2Table(org.apache.ignite.internal.processors.query.h2.opt.GridH2Table) ArrayList(java.util.ArrayList) IgniteSQLException(org.apache.ignite.internal.processors.query.IgniteSQLException)

Aggregations

GridH2Table (org.apache.ignite.internal.processors.query.h2.opt.GridH2Table)66 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)26 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)26 GridH2RowDescriptor (org.apache.ignite.internal.processors.query.h2.opt.GridH2RowDescriptor)18 GridSqlColumn (org.apache.ignite.internal.processors.query.h2.sql.GridSqlColumn)18 Column (org.h2.table.Column)18 ArrayList (java.util.ArrayList)16 IgniteException (org.apache.ignite.IgniteException)15 HashSet (java.util.HashSet)13 GridSqlElement (org.apache.ignite.internal.processors.query.h2.sql.GridSqlElement)12 GridQueryTypeDescriptor (org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor)11 GridSqlTable (org.apache.ignite.internal.processors.query.h2.sql.GridSqlTable)11 SQLException (java.sql.SQLException)10 List (java.util.List)10 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)10 GridSqlSelect (org.apache.ignite.internal.processors.query.h2.sql.GridSqlSelect)8 Map (java.util.Map)7 IgniteEx (org.apache.ignite.internal.IgniteEx)7 GridQueryProperty (org.apache.ignite.internal.processors.query.GridQueryProperty)7 HashMap (java.util.HashMap)5