Search in sources :

Example 11 with SchemaColumn

use of org.voltdb.plannodes.SchemaColumn in project voltdb by VoltDB.

the class ParsedSelectStmt method prepareMVBasedQueryFix.

/**
     * Prepare for the mv based distributed query fix only if it might be required.
     */
private void prepareMVBasedQueryFix() {
    // aggregation push down does not need reAggregation work.
    if (m_hasComplexGroupby) {
        m_mvFixInfo.setEdgeCaseQueryNoFixNeeded(false);
    }
    // that need to be fixed should not exceed one.
    for (StmtTableScan mvTableScan : allScans()) {
        Set<SchemaColumn> mvNewScanColumns = new HashSet<>();
        Collection<SchemaColumn> columns = mvTableScan.getScanColumns();
        // TB has no scan columns
        if (columns != null) {
            mvNewScanColumns.addAll(columns);
        }
        // also need to be checked.
        if (m_mvFixInfo.processMVBasedQueryFix(mvTableScan, mvNewScanColumns, m_joinTree, m_aggResultColumns, groupByColumns())) {
            break;
        }
    }
}
Also used : SchemaColumn(org.voltdb.plannodes.SchemaColumn) StmtTableScan(org.voltdb.planner.parseinfo.StmtTableScan) HashSet(java.util.HashSet)

Example 12 with SchemaColumn

use of org.voltdb.plannodes.SchemaColumn in project voltdb by VoltDB.

the class ParsedSelectStmt method isPartitionColumnInWindowedAggregatePartitionByList.

/**
     * Return true iff all the windowed partition expressions
     * have a table partition column in their partition by list,
     * and if there is one such windowed partition expression.
     * If there are no windowed expressions, we return false.
     * Note that there can only be one windowed
     * expression currently, so this is more general than it needs to be.
     *
     * @return
     */
public boolean isPartitionColumnInWindowedAggregatePartitionByList() {
    if (getWindowFunctionExpressions().size() == 0) {
        return false;
    }
    // If we ever do, this should fail gracelessly.
    assert (getWindowFunctionExpressions().size() == 1);
    WindowFunctionExpression we = getWindowFunctionExpressions().get(0);
    List<AbstractExpression> partitionByExprs = we.getPartitionByExpressions();
    boolean foundPartExpr = false;
    for (AbstractExpression ae : partitionByExprs) {
        if (!(ae instanceof TupleValueExpression)) {
            continue;
        }
        TupleValueExpression tve = (TupleValueExpression) ae;
        String tableAlias = tve.getTableAlias();
        String columnName = tve.getColumnName();
        StmtTableScan scanTable = getStmtTableScanByAlias(tableAlias);
        if (scanTable == null || scanTable.getPartitioningColumns() == null) {
            continue;
        }
        boolean foundPartCol = false;
        for (SchemaColumn pcol : scanTable.getPartitioningColumns()) {
            if (pcol != null && pcol.getColumnName().equals(columnName)) {
                foundPartCol = true;
                break;
            }
        }
        // in this windowed expression.
        if (foundPartCol) {
            foundPartExpr = true;
            break;
        }
    }
    return foundPartExpr;
}
Also used : TupleValueExpression(org.voltdb.expressions.TupleValueExpression) AbstractExpression(org.voltdb.expressions.AbstractExpression) WindowFunctionExpression(org.voltdb.expressions.WindowFunctionExpression) SchemaColumn(org.voltdb.plannodes.SchemaColumn) StmtTableScan(org.voltdb.planner.parseinfo.StmtTableScan)

Example 13 with SchemaColumn

use of org.voltdb.plannodes.SchemaColumn in project voltdb by VoltDB.

the class StmtSubqueryScan method addPartitioningColumns.

private void addPartitioningColumns(List<SchemaColumn> scols) {
    // in order to be referenced on parent level.
    for (SchemaColumn partitionCol : scols) {
        SchemaColumn matchedCol = null;
        // Find whether the partition column is in output column list
        for (SchemaColumn outputCol : m_outputColumnList) {
            AbstractExpression outputExpr = outputCol.getExpression();
            if (!(outputExpr instanceof TupleValueExpression)) {
                continue;
            }
            TupleValueExpression tve = (TupleValueExpression) outputExpr;
            if (tve.getTableName().equals(partitionCol.getTableName()) && tve.getColumnName().equals(partitionCol.getColumnName())) {
                matchedCol = outputCol;
                break;
            }
        }
        String colNameForParentQuery;
        if (matchedCol != null) {
            colNameForParentQuery = matchedCol.getColumnAlias();
        } else // including partition column in its display column list
        if (!m_subqueriesPartitioning.requiresTwoFragments()) {
            colNameForParentQuery = partitionCol.getColumnName();
        } else {
            continue;
        }
        partitionCol.reset(m_tableAlias, m_tableAlias, colNameForParentQuery, colNameForParentQuery);
        m_partitioningColumns.add(partitionCol);
    }
}
Also used : TupleValueExpression(org.voltdb.expressions.TupleValueExpression) AbstractExpression(org.voltdb.expressions.AbstractExpression) SchemaColumn(org.voltdb.plannodes.SchemaColumn)

Example 14 with SchemaColumn

use of org.voltdb.plannodes.SchemaColumn in project voltdb by VoltDB.

the class StmtSubqueryScan method getOutputExpression.

/** Produce a tuple value expression for a column produced by this subquery */
public TupleValueExpression getOutputExpression(int index) {
    SchemaColumn schemaCol = m_outputColumnList.get(index);
    TupleValueExpression tve = new TupleValueExpression(getTableAlias(), getTableAlias(), schemaCol.getColumnAlias(), schemaCol.getColumnAlias(), index);
    return tve;
}
Also used : TupleValueExpression(org.voltdb.expressions.TupleValueExpression) SchemaColumn(org.voltdb.plannodes.SchemaColumn)

Example 15 with SchemaColumn

use of org.voltdb.plannodes.SchemaColumn in project voltdb by VoltDB.

the class StmtTargetTableScan method findPartitioningColumns.

private List<SchemaColumn> findPartitioningColumns() {
    if (m_partitioningColumns != null) {
        return m_partitioningColumns;
    }
    if (getIsReplicated()) {
        return null;
    }
    Column partitionCol = m_table.getPartitioncolumn();
    // because it has no recognized partitioning join key.
    if (partitionCol == null) {
        return null;
    }
    String tbName = m_table.getTypeName();
    TupleValueExpression tve = new TupleValueExpression(tbName, m_tableAlias, partitionCol, partitionCol.getIndex());
    String colName = partitionCol.getTypeName();
    SchemaColumn scol = new SchemaColumn(tbName, m_tableAlias, colName, colName, tve);
    m_partitioningColumns = new ArrayList<SchemaColumn>();
    m_partitioningColumns.add(scol);
    return m_partitioningColumns;
}
Also used : TupleValueExpression(org.voltdb.expressions.TupleValueExpression) SchemaColumn(org.voltdb.plannodes.SchemaColumn) Column(org.voltdb.catalog.Column) SchemaColumn(org.voltdb.plannodes.SchemaColumn)

Aggregations

SchemaColumn (org.voltdb.plannodes.SchemaColumn)37 AbstractExpression (org.voltdb.expressions.AbstractExpression)19 TupleValueExpression (org.voltdb.expressions.TupleValueExpression)16 AbstractPlanNode (org.voltdb.plannodes.AbstractPlanNode)13 NodeSchema (org.voltdb.plannodes.NodeSchema)13 ProjectionPlanNode (org.voltdb.plannodes.ProjectionPlanNode)6 HashSet (java.util.HashSet)5 StmtTableScan (org.voltdb.planner.parseinfo.StmtTableScan)5 AbstractScanPlanNode (org.voltdb.plannodes.AbstractScanPlanNode)5 NestLoopPlanNode (org.voltdb.plannodes.NestLoopPlanNode)5 Table (org.voltdb.catalog.Table)4 OrderByPlanNode (org.voltdb.plannodes.OrderByPlanNode)4 SeqScanPlanNode (org.voltdb.plannodes.SeqScanPlanNode)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Column (org.voltdb.catalog.Column)3 Constraint (org.voltdb.catalog.Constraint)3 AbstractReceivePlanNode (org.voltdb.plannodes.AbstractReceivePlanNode)3 SendPlanNode (org.voltdb.plannodes.SendPlanNode)3 Set (java.util.Set)2