Skip to content

Commit

Permalink
fix(processor): dates in clickhouse queries (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
hekike authored Aug 15, 2023
1 parent 72d6c16 commit 5b6f5c5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions internal/streaming/clickhouse_connector/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ func (d queryMeterView) toSQL() (string, []interface{}, error) {
where = append(where, queryView.Equal("subject", *d.Subject))
}
if d.From != nil {
where = append(where, queryView.GreaterEqualThan("windowstart", d.From.UnixMilli()))
where = append(where, queryView.GreaterEqualThan("windowstart", d.From.Unix()))
}
if d.To != nil {
where = append(where, queryView.LessEqualThan("windowend", d.To.UnixMilli()))
where = append(where, queryView.LessEqualThan("windowend", d.To.Unix()))
}
if len(where) > 0 {
queryView.Where(where...)
Expand Down
2 changes: 1 addition & 1 deletion internal/streaming/clickhouse_connector/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func TestQueryMeterView(t *testing.T) {
WindowSize: &windowSize,
},
wantSQL: "SELECT windowstart, windowend, subject, sumMerge(value) AS value, group1, group2 FROM openmeter.meter_meter1 WHERE subject = ? AND windowstart >= ? AND windowend <= ? GROUP BY windowstart, windowend, subject, group1, group2 ORDER BY windowstart",
wantArgs: []interface{}{"subject1", int64(1672531200001), int64(1672617600000)},
wantArgs: []interface{}{"subject1", int64(1672531200), int64(1672617600)},
},
}

Expand Down

0 comments on commit 5b6f5c5

Please sign in to comment.