|
1 | 1 | package org.dbsp.sqlCompiler.compiler.sql.simple; |
2 | 2 |
|
| 3 | +import org.dbsp.sqlCompiler.circuit.DBSPCircuit; |
3 | 4 | import org.dbsp.sqlCompiler.circuit.annotation.OperatorHash; |
4 | 5 | import org.dbsp.sqlCompiler.circuit.operator.DBSPAggregateLinearPostprocessOperator; |
| 6 | +import org.dbsp.sqlCompiler.circuit.operator.DBSPAggregateOperatorBase; |
5 | 7 | import org.dbsp.sqlCompiler.circuit.operator.DBSPChainAggregateOperator; |
| 8 | +import org.dbsp.sqlCompiler.circuit.operator.DBSPPartitionedRollingAggregateOperator; |
| 9 | +import org.dbsp.sqlCompiler.circuit.operator.DBSPSimpleOperator; |
6 | 10 | import org.dbsp.sqlCompiler.circuit.operator.DBSPStreamAggregateOperator; |
7 | 11 | import org.dbsp.sqlCompiler.compiler.DBSPCompiler; |
8 | 12 | import org.dbsp.sqlCompiler.circuit.operator.DBSPWindowOperator; |
|
12 | 16 | import org.dbsp.sqlCompiler.compiler.visitors.outer.CircuitVisitor; |
13 | 17 | import org.dbsp.sqlCompiler.ir.aggregate.DBSPFold; |
14 | 18 | import org.dbsp.sqlCompiler.ir.aggregate.DBSPMinMax; |
| 19 | +import org.dbsp.sqlCompiler.ir.aggregate.IAggregate; |
15 | 20 | import org.dbsp.util.HashString; |
16 | 21 | import org.dbsp.util.NullPrintStream; |
17 | 22 | import org.dbsp.util.Utilities; |
@@ -458,6 +463,36 @@ public void endVisit() { |
458 | 463 | TestUtil.assertMessagesContain(compiler, "Column 'z' of table 't' is unused"); |
459 | 464 | } |
460 | 465 |
|
| 466 | + @Test |
| 467 | + public void issue2234() { |
| 468 | + var ccs = this.getCCS(""" |
| 469 | + CREATE TABLE transaction_with_customer(id INT, amt INT64, cc_num VARCHAR, unix_time INT64); |
| 470 | + CREATE VIEW FEATURE AS |
| 471 | + SELECT |
| 472 | + id, |
| 473 | + SUM(amt) OVER window_60_minute AS trans500_60min |
| 474 | + FROM transaction_with_customer as t |
| 475 | + WINDOW |
| 476 | + window_60_minute AS (PARTITION BY cc_num ORDER BY t.unix_time RANGE BETWEEN 3600 PRECEDING AND CURRENT ROW);"""); |
| 477 | + ccs.visit(new CircuitVisitor(ccs.compiler) { |
| 478 | + int aggregates = 0; |
| 479 | + |
| 480 | + @Override |
| 481 | + public void postorder(DBSPSimpleOperator operator) { |
| 482 | + if (operator.is(DBSPAggregateOperatorBase.class)) { |
| 483 | + Assert.assertTrue(operator.is(DBSPPartitionedRollingAggregateOperator.class)); |
| 484 | + this.aggregates++; |
| 485 | + } |
| 486 | + } |
| 487 | + |
| 488 | + @Override |
| 489 | + public void endVisit() { |
| 490 | + Assert.assertEquals(1, this.aggregates); |
| 491 | + super.endVisit(); |
| 492 | + } |
| 493 | + }); |
| 494 | + } |
| 495 | + |
461 | 496 | @Test |
462 | 497 | public void testEmptyAggregate() { |
463 | 498 | // After optimization an aggregate is completely removed |
|
0 commit comments