Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/pipeline-manager/src/compiler/sql_compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ mod test {
.create_pipeline(tenant_id, "p1", "v0", program_code)
.await;
test.sql_compiler_tick().await;
test.check_outcome_sql_compiled(tenant_id, pipeline_id, program_code)
test.check_outcome_sql_compiled(tenant_id, pipeline_id, program_code, true)
.await;
test.delete_pipeline(tenant_id, pipeline_id, "p1").await;
test.sql_compiler_tick().await;
Expand Down Expand Up @@ -1218,7 +1218,7 @@ mod test {
.await;
test.sql_compiler_tick().await;
let pipeline_descr = test
.check_outcome_sql_compiled(tenant_id, pipeline_id, program_code)
.check_outcome_sql_compiled(tenant_id, pipeline_id, program_code, false)
.await;

// Check the types of the table and view
Expand Down Expand Up @@ -1406,7 +1406,7 @@ mod test {
.await;
test.sql_compiler_tick().await;
let pipeline_descr = test
.check_outcome_sql_compiled(tenant_id, pipeline_id, program_code)
.check_outcome_sql_compiled(tenant_id, pipeline_id, program_code, false)
.await;

// Check materialized outcome
Expand Down Expand Up @@ -1471,7 +1471,7 @@ mod test {

// Check result
let pipeline_descr = test
.check_outcome_sql_compiled(tenant_id, pipeline_id, program_code)
.check_outcome_sql_compiled(tenant_id, pipeline_id, program_code, false)
.await;
let input_connectors = validate_program_info(&pipeline_descr.program_info.clone().unwrap())
.unwrap()
Expand Down
5 changes: 4 additions & 1 deletion crates/pipeline-manager/src/compiler/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ impl CompilerTest {
tenant_id: TenantId,
pipeline_id: PipelineId,
program_code: &str,
warnings: bool,
) -> ExtendedPipelineDescr {
// Retrieve pipeline descriptor
let pipeline_descr = self.get_pipeline(tenant_id, pipeline_id).await;
Expand Down Expand Up @@ -271,7 +272,9 @@ impl CompilerTest {
);
assert_eq!(content_program_sql, program_code);
assert_ne!(content_schema_json, "");
assert_eq!(content_stderr_log, "");
if (!warnings) {
assert_eq!(content_stderr_log, "");
}
assert_eq!(content_stdout_log, "");

// Return the pipeline descriptor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public VisitDecision preorder(DBSPApplyMethodExpression unused) {

@Override
public VisitDecision preorder(DBSPBinaryExpression expression) {
// Lowered to a runtime function call
if (expression.opcode == DBSPOpcode.VARIANT_INDEX) {
this.expensive = true;
return VisitDecision.STOP;
Expand All @@ -82,7 +81,6 @@ public VisitDecision preorder(DBSPBinaryExpression expression) {

@Override
public VisitDecision preorder(DBSPCastExpression expression) {
// VARIANT casts are lowered to runtime function calls
if (expression.getType().is(DBSPTypeVariant.class) ||
expression.source.getType().is(DBSPTypeVariant.class)) {
this.expensive = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public VisitDecision preorder(DBSPLetExpression expression) {
expression.initializer.accept(this);
this.substitutionContext.newContext();
this.substitutionContext.substitute(expression.variable.variable, expression);
this.reference.declare(expression.variable, expression);
expression.consumer.accept(this);
this.substitutionContext.popContext();
return VisitDecision.STOP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ void createOptimizer() {
AnalyzedSet<DBSPOperator> operatorsAnalyzed = new AnalyzedSet<>();
this.add(new OptimizeWithGraph(compiler,
g -> new OptimizeProjections(compiler, true, g, operatorsAnalyzed), 1));
this.add(new FuseExpensiveMaps(compiler));
this.add(new RemoveViewOperators(compiler, false));
this.add(new UnusedFields(compiler));
this.add(new Intern(compiler));
Expand Down Expand Up @@ -173,6 +174,7 @@ void createOptimizer() {
this.add(new OptimizeWithGraph(compiler, g -> new StrayGC(compiler, g)));
// The canonical form is needed if we want the Merkle hashes to be "stable".
this.add(new CanonicalForm(compiler).getCircuitRewriter(false));
this.add(new ConstantViews(compiler));
this.add(new StaticDeclarations(compiler, new ImplementStatics(compiler, !compiler.options.ioOptions.multiCrates())));
// From now on we cannot really change the graph anymore.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.dbsp.sqlCompiler.compiler.visitors.outer;

import org.dbsp.sqlCompiler.circuit.OutputPort;
import org.dbsp.sqlCompiler.circuit.operator.DBSPConstantOperator;
import org.dbsp.sqlCompiler.circuit.operator.DBSPDifferentiateOperator;
import org.dbsp.sqlCompiler.circuit.operator.DBSPSinkOperator;
import org.dbsp.sqlCompiler.compiler.DBSPCompiler;

import java.util.HashSet;
import java.util.Set;

/** Give a warning when a view is fed from a constant operator
* (via potentially a differentiator) */
public class ConstantViews extends CircuitVisitor {
final Set<OutputPort> constant = new HashSet<>();

public ConstantViews(DBSPCompiler compiler) {
super(compiler);
}

@Override
public void postorder(DBSPConstantOperator operator) {
this.constant.add(operator.outputPort());
}

@Override
public void postorder(DBSPDifferentiateOperator operator) {
if (this.constant.contains(operator.input())) {
this.constant.add(operator.outputPort());
}
}

@Override
public void postorder(DBSPSinkOperator operator) {
if (operator.viewName.equals(DBSPCompiler.ERROR_VIEW_NAME))
return;
if (this.constant.contains(operator.input())) {
this.compiler.reportWarning(
operator.getSourcePosition(),
"View is constant",
"View " + operator.viewName.singleQuote() + " does not depend on any input data");
}
}
}
Loading