Skip to content

Commit

Permalink
fix(cubestore): Correct convert_tz implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
paveltiunov committed Jan 29, 2021
1 parent 5fe3431 commit f06d91e
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 24 deletions.
48 changes: 24 additions & 24 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions rust/cubestore/src/sql/mod.rs
Expand Up @@ -1987,6 +1987,48 @@ mod tests {
.await;
}

#[tokio::test]
async fn convert_tz() {
Config::run_test("convert_tz", async move |services| {
let service = services.sql_service;

service.exec_query("CREATE SCHEMA foo").await.unwrap();

service
.exec_query("CREATE TABLE foo.timestamps (t timestamp, amount int)")
.await
.unwrap();

service
.exec_query(
"INSERT INTO foo.timestamps (t, amount) VALUES \
('2020-01-01T00:00:00.000Z', 1), \
('2020-01-01T00:01:00.000Z', 2), \
('2020-01-02T00:10:00.000Z', 3)",
)
.await
.unwrap();

let result = service
.exec_query(
"SELECT date_trunc('day', `t`) `day`, sum(`amount`) \
FROM foo.timestamps `timestamp` \
WHERE `t` >= convert_tz(to_timestamp('2020-01-02T08:00:00.000Z'), '+08:00') GROUP BY 1",
)
.await
.unwrap();

assert_eq!(
result.get_rows()[0],
Row::new(vec![
TableValue::Timestamp(TimestampValue::new(1577923200000000000)),
TableValue::Int(3)
])
);
})
.await;
}

#[tokio::test]
async fn create_schema_if_not_exists() {
Config::run_test("create_schema_if_not_exists", async move |services| {
Expand Down

0 comments on commit f06d91e

Please sign in to comment.