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
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@ void processSingle(SqlSingleValueAggFunction function) {
DBSPExpression increment = aggregatedValue;
if (!increment.getType().mayBeNull)
increment = increment.some();
DBSPType semigroup = new DBSPTypeUser(CalciteObject.EMPTY, SEMIGROUP, "DefaultOptSemigroup",
false, accumulator.getType().setMayBeNull(false));
DBSPType semigroup = new DBSPTypeUser(CalciteObject.EMPTY, SEMIGROUP, "UnimplementedSemigroup",
false, accumulator.getType());
this.setFoldingFunction(new DBSPAggregate.Implementation(
node, zero, this.makeRowClosure(increment, accumulator), zero, semigroup, null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,31 @@ public Change createInput() {
return new Change(new DBSPZSetLiteral(new DBSPTupleExpression(new DBSPTimestampLiteral(100))));
}

@Test
public void issue1843() {
String sql = """
create table credit_card_transactions(transaction_time timestamp);

create table my_timer(t timestamp);\s

create view recent_transactions as
SELECT * FROM credit_card_transactions
WHERE transaction_time >= (SELECT t FROM my_timer) - INTERVAL 1 DAY;""";
this.compileRustTestCase(sql);
}

@Test
public void issue1844() {
String sql = """
create table credit_card_transactions(transaction_time timestamp);
create table my_timer(id int primary key, t timestamp);\s

create view recent_transactions as
SELECT * FROM credit_card_transactions
WHERE transaction_time >= (SELECT DATE_SUB(t, INTERVAL 1 DAY) FROM my_timer);""";
this.compileRustTestCase(sql);
}

@Test
public void testInterval() {
this.testQuery("SELECT INTERVAL '20' YEAR",
Expand Down
8 changes: 8 additions & 0 deletions sql-to-dbsp-compiler/lib/sqllib/src/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,14 @@ polymorphic_return_function2!(
Timestamp
);

pub fn minus_Date_ShortInterval_Date(left: Date, right: ShortInterval) -> Date {
let days = (right.milliseconds() / (86400 * 1000)) as i32;
let diff = left.days() - days;
Date::new(diff)
}

polymorphic_return_function2!(minus, Date, Date, ShortInterval, ShortInterval, Date, Date);

pub fn minus_Timestamp_Timestamp_LongInterval(left: Timestamp, right: Timestamp) -> LongInterval {
let ldate = left.to_dateTime();
let rdate = right.to_dateTime();
Expand Down