You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running a query with group by and built-in functions in Clickhouse the correct result is not returned compared with running the exact same query on the Clickhouse command line. This was tested within actix-web.
Steps to reproduce
Run query on the Clickhouse CLI.
Execute database query within route handler in actix-web
Expected behaviour
Only 1 - 3 rows are returned when the limit number should be returned.
Code example
use actix_web::{get, web, HttpResponse, Responder};
use clickhouse::{Client, Row};
use serde::{Deserialize, Serialize};
use time::{OffsetDateTime};
#[derive(Debug, Row, Deserialize, Serialize)]
struct StockRow<'a> {
ticker: &'a str,
#[serde(with = "clickhouse::serde::time::datetime")]
stock_timestamp: OffsetDateTime,
open: f32,
high: f32,
low: f32,
close: f32,
volume: u32,
}
#[get("/api/data")]
async fn api_data(
client: web::Data<Client>,
params: web::Query<QueryParams>,
) -> Result<impl Responder, actix_web::Error> {
let ticker = ¶ms.ticker;
let limit: i16 = match params.limit {
Some(limit) => limit,
None => 100,
};
let mut cursor = client
.query("SELECT ticker, toStartOfMinute(stock_timestamp) stock_timestamp, argMin(open, stock_timestamp) AS open,
MAX(high) AS high,
MIN(low) AS low,
argMax(close, stock_timestamp) AS close,
SUM(volume) AS volume FROM stocks WHERE ticker = ? GROUP BY ticker, stock_timestamp ORDER BY stock_timestamp LIMIT ?")
.bind(ticker)
.bind(limit)
.fetch::<StockRow<'_>>()
.unwrap();
while let Ok(Some(row)) = cursor.next().await {
println!("{:?}", row);
}
Ok(HttpResponse::Ok().body(""))
}
Error log
No errors, incorrect result is returned.
Query log
This query can be tested using the Clickhouse CLI:
SELECT
ticker,
toStartOfMinute(stock_timestamp) AS stock_timestamp,
argMin(open, stock_timestamp) AS open,
MAX(high) AS high,
MIN(low) AS low,
argMax(close, stock_timestamp) AS close,
SUM(volume) AS volume
FROM stocks
WHERE ticker = 'NVDA'
GROUP BY ticker, stock_timestamp
ORDER BY stock_timestamp
LIMIT 100;
Describe the bug
When running a query with group by and built-in functions in Clickhouse the correct result is not returned compared with running the exact same query on the Clickhouse command line. This was tested within actix-web.
Steps to reproduce
Expected behaviour
Only 1 - 3 rows are returned when the limit number should be returned.
Code example
Error log
No errors, incorrect result is returned.
Query log
This query can be tested using the Clickhouse CLI:
Configuration
Environment
ClickHouse server
CREATE TABLE
statements for tables involved:Sample data was outputted as JSON from Clickhouse:
The text was updated successfully, but these errors were encountered: