Package org.voltdb.planner

Examples of org.voltdb.planner.ParsedSelectStmt


                e.printStackTrace();
            }
            assert(xmlquery != null);

            // parse the xml like any other sql statement
            ParsedSelectStmt stmt = null;
            try {
                stmt = (ParsedSelectStmt) AbstractParsedStmt.parse(query, xmlquery, db);
            }
            catch (Exception e) {
                throw m_compiler.new VoltCompilerException(e.getMessage());
View Full Code Here


        String name = node.attributes.get("name");
        boolean unique = Boolean.parseBoolean(node.attributes.get("unique"));
        boolean assumeUnique = Boolean.parseBoolean(node.attributes.get("assumeunique"));

        AbstractParsedStmt dummy = new ParsedSelectStmt(null, db);
        dummy.setTable(table);

        // "parse" the expression trees for an expression-based index (vs. a simple column value index)
        List<AbstractExpression> exprs = null;
        for (VoltXMLElement subNode : node.children) {
            if (subNode.name.equals("exprs")) {
                exprs = new ArrayList<AbstractExpression>();
                for (VoltXMLElement exprNode : subNode.children) {
                    AbstractExpression expr = dummy.parseExpressionTree(exprNode);

                    if (containsTimeSensitiveFunction(expr, FunctionSQL.voltGetCurrentTimestampId()) ) {
                        String msg = String.format("Index %s cannot include the function NOW or CURRENT_TIMESTAMP.", name);
                        throw this.m_compiler.new VoltCompilerException(msg);
                    }
View Full Code Here

                e.printStackTrace();
            }
            assert(xmlquery != null);

            // parse the xml like any other sql statement
            ParsedSelectStmt stmt = null;
            try {
                stmt = (ParsedSelectStmt) AbstractParsedStmt.parse(query, xmlquery, null, db, null);
            }
            catch (Exception e) {
                throw m_compiler.new VoltCompilerException(e.getMessage());
            }
            assert(stmt != null);

            String viewName = destTable.getTypeName();
            // throw an error if the view isn't within voltdb's limited worldview
            checkViewMeetsSpec(viewName, stmt);

            // Allow only non-unique indexes other than the primary key index.
            // The primary key index is yet to be defined (below).
            for (Index destIndex : destTable.getIndexes()) {
                if (destIndex.getUnique() || destIndex.getAssumeunique()) {
                    String msg = "A UNIQUE or ASSUMEUNIQUE index is not allowed on a materialized view. " +
                            "Remove the qualifier from the index " + destIndex.getTypeName() +
                            "defined on the materialized view \"" + viewName + "\".";
                    throw m_compiler.new VoltCompilerException(msg);
                }
            }

            // create the materializedviewinfo catalog node for the source table
            Table srcTable = stmt.m_tableList.get(0);
            if (viewTableNames.contains(srcTable.getTypeName())) {
                String msg = String.format("A materialized view (%s) can not be defined on another view (%s).",
                        viewName, srcTable.getTypeName());
                throw m_compiler.new VoltCompilerException(msg);
            }

            MaterializedViewInfo matviewinfo = srcTable.getViews().add(viewName);
            matviewinfo.setDest(destTable);
            AbstractExpression where = stmt.getSingleTableFilterExpression();
            if (where != null) {
                String hex = Encoder.hexEncode(where.toJSONString());
                matviewinfo.setPredicate(hex);
            } else {
                matviewinfo.setPredicate("");
            }
            destTable.setMaterializer(srcTable);

            List<Column> srcColumnArray = CatalogUtil.getSortedCatalogItems(srcTable.getColumns(), "index");
            List<Column> destColumnArray = CatalogUtil.getSortedCatalogItems(destTable.getColumns(), "index");
            List<AbstractExpression> groupbyExprs = null;

            if (stmt.hasComplexGroupby()) {
                groupbyExprs = new ArrayList<AbstractExpression>();
                for (ParsedColInfo col: stmt.m_groupByColumns) {
                    groupbyExprs.add(col.expression);
                }
                // Parse group by expressions to json string
View Full Code Here

            m_hasReceiveNode = true;
            return root;
        }

        m_hasReceiveNode = true;
        ParsedSelectStmt selectStmt = (ParsedSelectStmt)m_subqueryStmt;
        if (selectStmt == null) {
            // Union are just returned
            assert(m_subqueryStmt instanceof ParsedUnionStmt);
            return root;
        }

        // Now If query has LIMIT/OFFSET/DISTINCT on a replicated table column,
        // we should get rid of the receive node.
        if (selectStmt.hasLimitOrOffset() || selectStmt.hasDistinct()) {
            return root;
        }

        // If the query contains the partition materialized table with the need to Re-aggregate,
        // then we can not get rid of the receive node.
        // This is also caught in StatementPartitioning when analysing the join criteria,
        // because it contains a partitioned view that does not have partition column.
        if (selectStmt.m_mvFixInfo.needed()) {
            return root;
        }

        // Table aggregate cases should not get rid of the receive node
        if (selectStmt.hasAggregateOrGroupby()) {
            if (!selectStmt.isGrouped()) {
                m_tableAggregateSubquery = true;
                return root;
            }
            // For group by queries, there are two cases on group by columns.
            // (1) Does not Contain the partition columns: If join with partition table on outer
            //     level, it will violates the join criteria.
            // Detect case (1) to mark receive node.
            if (! selectStmt.hasPartitionColumnInGroupby()) {
                return root;
            }

            //
            // (2) Group by columns contain the partition columns:
            //     This is the interesting case that we are going to support.
            //     At this point, subquery does not contain LIMIT/OFFSET.
            //     But if the aggregate has distinct, we have to compute on coordinator.
            if ( selectStmt.hasAggregateDistinct() ) {
                return root;
            }

            //     Now. If this sub-query joins with partition table on outer level,
            //     we are able to push the join down by removing the send/receive plan node pair.
View Full Code Here

TOP

Related Classes of org.voltdb.planner.ParsedSelectStmt

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.