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
1 change: 1 addition & 0 deletions asap-common/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
.vscode/

dependencies/py/promql_utilities/promql_utilities.egg-info/
dependencies/py/promql_utilities/build/
dependencies/rs/**/target/

tests/**/*.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,65 @@ mod tests {
);
}

// ── ClickHouse parametric syntax + explicit BETWEEN timestamps ────────────
// These verify that a fully ClickHouse-compatible query (no DATEADD, no NOW())
// is parseable by ASAP: quantile(q)(col) + BETWEEN 'start' AND 'end'.

#[test]
fn test_clickhouse_explicit_datetime_temporal_quantile() {
check_query(
"SELECT quantile(0.95)(value) FROM cpu_usage WHERE time BETWEEN '2025-10-01 00:00:00' AND '2025-10-01 00:00:10' GROUP BY L1, L2, L3, L4",
vec![QueryType::TemporalQuantile],
None,
);
}

#[test]
// ASAP-only: parse_datetime accepts the Z suffix (interprets as UTC), but ClickHouse
// rejects it with TYPE_MISMATCH when comparing against a DateTime column.
// Do not use Z-suffix strings in queries intended for both systems.
fn test_asap_only_iso_z_temporal_quantile() {
check_query(
"SELECT quantile(0.95)(value) FROM cpu_usage WHERE time BETWEEN '2025-10-01T00:00:00Z' AND '2025-10-01T00:00:10Z' GROUP BY L1, L2, L3, L4",
vec![QueryType::TemporalQuantile],
None,
);
}

#[test]
// Both ASAP (parse_datetime) and ClickHouse treat ISO-without-Z as local server time.
// They agree only when running in the same timezone; prefer 'YYYY-MM-DD HH:MM:SS'
// (space format) to avoid this implicit dependency.
fn test_iso_no_z_treated_as_local_time_temporal_quantile() {
check_query(
"SELECT quantile(0.95)(value) FROM cpu_usage WHERE time BETWEEN '2025-10-01T00:00:00' AND '2025-10-01T00:00:10' GROUP BY L1, L2, L3, L4",
vec![QueryType::TemporalQuantile],
None,
);
}

#[test]
fn test_clickhouse_explicit_datetime_spatial_quantile() {
check_query(
"SELECT quantile(0.95)(value) FROM cpu_usage WHERE time BETWEEN '2025-10-01 00:00:00' AND '2025-10-01 00:00:01' GROUP BY L1",
vec![QueryType::Spatial],
None,
);
}

#[test]
fn test_clickhouse_explicit_matches_now_template() {
// A ClickHouse-style query (explicit timestamps, parametric quantile) must
// match a stored DATEADD(NOW()) template of the same shape.
let template = parse_sql_query(
"SELECT quantile(0.95)(value) FROM cpu_usage WHERE time BETWEEN DATEADD(s, -10, NOW()) AND NOW() GROUP BY L1, L2, L3, L4"
).unwrap();
let incoming = parse_sql_query(
"SELECT quantile(0.95)(value) FROM cpu_usage WHERE time BETWEEN '2025-10-01 00:00:00' AND '2025-10-01 00:00:10' GROUP BY L1, L2, L3, L4"
).unwrap();
assert!(incoming.matches_sql_pattern(&template));
}

// ── Error cases ──────────────────────────────────────────────────────────

#[test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ impl SQLPatternParser {
}

fn get_timestamp_from_datetime_str(datetime_str: &str) -> Option<f64> {
// parse_datetime treats timezone-naive strings (e.g. "2025-10-01 00:00:00",
// "2025-10-01T00:00:00") as local server time, matching ClickHouse's behavior —
// but only when both run in the same timezone. Z-suffix strings (e.g.
// "2025-10-01T00:00:00Z") are interpreted as UTC here but rejected by ClickHouse.
// Use space-format datetime strings ("YYYY-MM-DD HH:MM:SS") for portability.
let parsed_datetime = parse_datetime(datetime_str).ok()?;
Some(parsed_datetime.timestamp().as_second() as f64)
}
Expand Down
1 change: 1 addition & 0 deletions asap-query-engine/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
target
output/
1 change: 1 addition & 0 deletions asap-summary-ingest/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
__pycache__
**/*.pyc
**/*.swp
outputs/
3 changes: 3 additions & 0 deletions asap-tools/execution-utilities/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

clickhouse-benchmark-pipeline/benchmark_results/
**/data/
benchmark/arroyo_outputs/
benchmark/queries/
benchmark/results/

**/*.csv
**/*.png
Loading
Loading