Search in sources :

Example 1 with BoundAlterTable

use of io.crate.analyze.BoundAlterTable in project crate by crate.

the class AlterBlobTablePlan method executeOrFail.

@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) {
    Function<? super Symbol, Object> eval = x -> SymbolEvaluator.evaluate(plannerContext.transactionContext(), plannerContext.nodeContext(), x, params, subQueryResults);
    TableInfo tableInfo = analyzedAlterTable.tableInfo();
    AlterTable<Object> alterTable = analyzedAlterTable.alterTable().map(eval);
    TableParameter tableParameter = getTableParameter(alterTable, TableParameters.ALTER_BLOB_TABLE_PARAMETERS);
    maybeRaiseBlockedException(tableInfo, tableParameter.settings());
    BoundAlterTable stmt = new BoundAlterTable(tableInfo, null, tableParameter, true, false);
    dependencies.alterTableOperation().executeAlterTable(stmt).whenComplete(new OneRowActionListener<>(consumer, rCount -> new Row1(rCount == null ? -1 : rCount)));
}
Also used : AlterTable(io.crate.sql.tree.AlterTable) TableParameter(io.crate.analyze.TableParameter) TableInfo(io.crate.metadata.table.TableInfo) BoundAlterTable(io.crate.analyze.BoundAlterTable) Function(java.util.function.Function) TableParameters(io.crate.analyze.TableParameters) RowConsumer(io.crate.data.RowConsumer) DependencyCarrier(io.crate.planner.DependencyCarrier) AnalyzedAlterBlobTable(io.crate.analyze.AnalyzedAlterBlobTable) AlterTablePlan.getTableParameter(io.crate.planner.node.ddl.AlterTablePlan.getTableParameter) SymbolEvaluator(io.crate.analyze.SymbolEvaluator) Row(io.crate.data.Row) Symbol(io.crate.expression.symbol.Symbol) PlannerContext(io.crate.planner.PlannerContext) Plan(io.crate.planner.Plan) SubQueryResults(io.crate.planner.operators.SubQueryResults) AlterTablePlan.maybeRaiseBlockedException(io.crate.planner.node.ddl.AlterTablePlan.maybeRaiseBlockedException) OneRowActionListener(io.crate.execution.support.OneRowActionListener) Row1(io.crate.data.Row1) Row1(io.crate.data.Row1) BoundAlterTable(io.crate.analyze.BoundAlterTable) TableParameter(io.crate.analyze.TableParameter) AlterTablePlan.getTableParameter(io.crate.planner.node.ddl.AlterTablePlan.getTableParameter) TableInfo(io.crate.metadata.table.TableInfo)

Example 2 with BoundAlterTable

use of io.crate.analyze.BoundAlterTable in project crate by crate.

the class AlterTablePlan method bind.

public static BoundAlterTable bind(AnalyzedAlterTable analyzedAlterTable, CoordinatorTxnCtx txnCtx, NodeContext nodeCtx, Row params, SubQueryResults subQueryResults) {
    Function<? super Symbol, Object> eval = x -> SymbolEvaluator.evaluate(txnCtx, nodeCtx, x, params, subQueryResults);
    DocTableInfo docTableInfo = analyzedAlterTable.tableInfo();
    AlterTable<Object> alterTable = analyzedAlterTable.alterTable().map(eval);
    Table<Object> table = alterTable.table();
    PartitionName partitionName = PartitionPropertiesAnalyzer.createPartitionName(table.partitionProperties(), docTableInfo);
    TableParameters tableParameters = getTableParameterInfo(table, partitionName);
    TableParameter tableParameter = getTableParameter(alterTable, tableParameters);
    maybeRaiseBlockedException(docTableInfo, tableParameter.settings());
    return new BoundAlterTable(docTableInfo, partitionName, tableParameter, table.excludePartitions(), docTableInfo.isPartitioned());
}
Also used : AlterTable(io.crate.sql.tree.AlterTable) AnalyzedAlterTable(io.crate.analyze.AnalyzedAlterTable) BoundAlterTable(io.crate.analyze.BoundAlterTable) IndexMetadata(org.elasticsearch.cluster.metadata.IndexMetadata) PartitionPropertiesAnalyzer(io.crate.analyze.PartitionPropertiesAnalyzer) Operation(io.crate.metadata.table.Operation) Function(java.util.function.Function) PartitionName(io.crate.metadata.PartitionName) DependencyCarrier(io.crate.planner.DependencyCarrier) SymbolEvaluator(io.crate.analyze.SymbolEvaluator) Settings(org.elasticsearch.common.settings.Settings) OneRowActionListener(io.crate.execution.support.OneRowActionListener) Nullable(javax.annotation.Nullable) TableParameter(io.crate.analyze.TableParameter) DocTableInfo(io.crate.metadata.doc.DocTableInfo) TableInfo(io.crate.metadata.table.TableInfo) NodeContext(io.crate.metadata.NodeContext) TablePropertiesAnalyzer(io.crate.analyze.TablePropertiesAnalyzer) Table(io.crate.sql.tree.Table) TableParameters(io.crate.analyze.TableParameters) RowConsumer(io.crate.data.RowConsumer) Row(io.crate.data.Row) Symbol(io.crate.expression.symbol.Symbol) PlannerContext(io.crate.planner.PlannerContext) Plan(io.crate.planner.Plan) SubQueryResults(io.crate.planner.operators.SubQueryResults) Row1(io.crate.data.Row1) CoordinatorTxnCtx(io.crate.metadata.CoordinatorTxnCtx) PartitionName(io.crate.metadata.PartitionName) DocTableInfo(io.crate.metadata.doc.DocTableInfo) BoundAlterTable(io.crate.analyze.BoundAlterTable) TableParameter(io.crate.analyze.TableParameter) TableParameters(io.crate.analyze.TableParameters)

Example 3 with BoundAlterTable

use of io.crate.analyze.BoundAlterTable in project crate by crate.

the class AlterTablePlan method executeOrFail.

@Override
public void executeOrFail(DependencyCarrier dependencies, PlannerContext plannerContext, RowConsumer consumer, Row params, SubQueryResults subQueryResults) throws Exception {
    BoundAlterTable stmt = bind(alterTable, plannerContext.transactionContext(), dependencies.nodeContext(), params, subQueryResults);
    dependencies.alterTableOperation().executeAlterTable(stmt).whenComplete(new OneRowActionListener<>(consumer, rCount -> new Row1(rCount == null ? -1 : rCount)));
}
Also used : AlterTable(io.crate.sql.tree.AlterTable) AnalyzedAlterTable(io.crate.analyze.AnalyzedAlterTable) BoundAlterTable(io.crate.analyze.BoundAlterTable) IndexMetadata(org.elasticsearch.cluster.metadata.IndexMetadata) PartitionPropertiesAnalyzer(io.crate.analyze.PartitionPropertiesAnalyzer) Operation(io.crate.metadata.table.Operation) Function(java.util.function.Function) PartitionName(io.crate.metadata.PartitionName) DependencyCarrier(io.crate.planner.DependencyCarrier) SymbolEvaluator(io.crate.analyze.SymbolEvaluator) Settings(org.elasticsearch.common.settings.Settings) OneRowActionListener(io.crate.execution.support.OneRowActionListener) Nullable(javax.annotation.Nullable) TableParameter(io.crate.analyze.TableParameter) DocTableInfo(io.crate.metadata.doc.DocTableInfo) TableInfo(io.crate.metadata.table.TableInfo) NodeContext(io.crate.metadata.NodeContext) TablePropertiesAnalyzer(io.crate.analyze.TablePropertiesAnalyzer) Table(io.crate.sql.tree.Table) TableParameters(io.crate.analyze.TableParameters) RowConsumer(io.crate.data.RowConsumer) Row(io.crate.data.Row) Symbol(io.crate.expression.symbol.Symbol) PlannerContext(io.crate.planner.PlannerContext) Plan(io.crate.planner.Plan) SubQueryResults(io.crate.planner.operators.SubQueryResults) Row1(io.crate.data.Row1) CoordinatorTxnCtx(io.crate.metadata.CoordinatorTxnCtx) Row1(io.crate.data.Row1) BoundAlterTable(io.crate.analyze.BoundAlterTable)

Aggregations

BoundAlterTable (io.crate.analyze.BoundAlterTable)3 SymbolEvaluator (io.crate.analyze.SymbolEvaluator)3 TableParameter (io.crate.analyze.TableParameter)3 TableParameters (io.crate.analyze.TableParameters)3 Row (io.crate.data.Row)3 Row1 (io.crate.data.Row1)3 RowConsumer (io.crate.data.RowConsumer)3 OneRowActionListener (io.crate.execution.support.OneRowActionListener)3 Symbol (io.crate.expression.symbol.Symbol)3 TableInfo (io.crate.metadata.table.TableInfo)3 DependencyCarrier (io.crate.planner.DependencyCarrier)3 Plan (io.crate.planner.Plan)3 PlannerContext (io.crate.planner.PlannerContext)3 SubQueryResults (io.crate.planner.operators.SubQueryResults)3 AlterTable (io.crate.sql.tree.AlterTable)3 Function (java.util.function.Function)3 AnalyzedAlterTable (io.crate.analyze.AnalyzedAlterTable)2 PartitionPropertiesAnalyzer (io.crate.analyze.PartitionPropertiesAnalyzer)2 TablePropertiesAnalyzer (io.crate.analyze.TablePropertiesAnalyzer)2 CoordinatorTxnCtx (io.crate.metadata.CoordinatorTxnCtx)2