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;
}
}
}
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;
}
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);
}
}
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;
}
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;
}
Aggregations