@Override public ILogicalOperator visitInsertDeleteUpsertOperator(InsertDeleteUpsertOperator op, Void arg) throws AlgebricksException { List<Mutable<ILogicalExpression>> newKeyExpressions = new ArrayList<>(); deepCopyExpressionRefs(newKeyExpressions, op.getPrimaryKeyExpressions()); List<Mutable<ILogicalExpression>> newLSMComponentFilterExpressions = new ArrayList<>(); deepCopyExpressionRefs(newKeyExpressions, op.getAdditionalFilteringExpressions()); InsertDeleteUpsertOperator insertDeleteOp = new InsertDeleteUpsertOperator(op.getDataSource(), deepCopyExpressionRef(op.getPayloadExpression()), newKeyExpressions, op.getOperation(), op.isBulkload()); insertDeleteOp.setAdditionalFilteringExpressions(newLSMComponentFilterExpressions); return insertDeleteOp; }
private ILogicalOperator translateDelete(DatasetDataSource targetDatasource, Mutable<ILogicalExpression> varRef, List<Mutable<ILogicalExpression>> varRefsForLoading, List<Mutable<ILogicalExpression>> additionalFilteringExpressions, ILogicalOperator assign, ICompiledDmlStatement stmt) throws AlgebricksException { SourceLocation sourceLoc = stmt.getSourceLocation(); if (targetDatasource.getDataset().hasMetaPart()) { throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc, targetDatasource.getDataset().getDatasetName() + ": delete from dataset is not supported on Datasets with Meta records"); } InsertDeleteUpsertOperator deleteOp = new InsertDeleteUpsertOperator(targetDatasource, varRef, varRefsForLoading, InsertDeleteUpsertOperator.Kind.DELETE, false); deleteOp.setAdditionalFilteringExpressions(additionalFilteringExpressions); deleteOp.getInputs().add(new MutableObject<>(assign)); deleteOp.setSourceLocation(sourceLoc); DelegateOperator leafOperator = new DelegateOperator(new CommitOperator(true)); leafOperator.getInputs().add(new MutableObject<>(deleteOp)); leafOperator.setSourceLocation(sourceLoc); return leafOperator; }
upsertOp = new InsertDeleteUpsertOperator(targetDatasource, varRef, varRefsForLoading, metaExpSingletonList, InsertDeleteUpsertOperator.Kind.UPSERT, false); upsertOp.setUpsertIndicatorVar(context.newVar()); upsertOp.setAdditionalFilteringExpressions(additionalFilteringExpressions); } else { upsertOp = new InsertDeleteUpsertOperator(targetDatasource, varRef, varRefsForLoading, InsertDeleteUpsertOperator.Kind.UPSERT, false); upsertOp.setAdditionalFilteringExpressions(additionalFilteringExpressions);
private ILogicalOperator translateInsert(DatasetDataSource targetDatasource, Mutable<ILogicalExpression> varRef, List<Mutable<ILogicalExpression>> varRefsForLoading, List<Mutable<ILogicalExpression>> additionalFilteringExpressions, ILogicalOperator assign, ICompiledDmlStatement stmt) throws AlgebricksException { SourceLocation sourceLoc = stmt.getSourceLocation(); if (targetDatasource.getDataset().hasMetaPart()) { throw new CompilationException(ErrorCode.COMPILATION_ERROR, sourceLoc, targetDatasource.getDataset().getDatasetName() + ": insert into dataset is not supported on Datasets with Meta records"); } // Adds the insert operator. InsertDeleteUpsertOperator insertOp = new InsertDeleteUpsertOperator(targetDatasource, varRef, varRefsForLoading, InsertDeleteUpsertOperator.Kind.INSERT, false); insertOp.setAdditionalFilteringExpressions(additionalFilteringExpressions); insertOp.getInputs().add(new MutableObject<>(assign)); insertOp.setSourceLocation(sourceLoc); // Adds the commit operator. CompiledInsertStatement compiledInsert = (CompiledInsertStatement) stmt; Expression returnExpression = compiledInsert.getReturnExpression(); DelegateOperator rootOperator = new DelegateOperator(new CommitOperator(returnExpression == null)); rootOperator.getInputs().add(new MutableObject<>(insertOp)); rootOperator.setSourceLocation(sourceLoc); // Compiles the return expression. return processReturningExpression(rootOperator, insertOp, compiledInsert); }
InsertDeleteUpsertOperator insertOp = new InsertDeleteUpsertOperator(targetDatasource, payloadRef, varRefsForLoading, InsertDeleteUpsertOperator.Kind.INSERT, true); insertOp.setAdditionalFilteringExpressions(additionalFilteringExpressions);