Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit 9f0162a

Browse files
committed
Add failing test to skip
1 parent 7cd9a04 commit 9f0162a

File tree

2 files changed

+367
-0
lines changed

2 files changed

+367
-0
lines changed

quesma/queryparser/pancake_sql_query_generation_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ func TestPancakeQueryGeneration(t *testing.T) {
5555
t.Skip("Fix filters")
5656
}
5757

58+
if test.TestName == "Line, Y-axis: Min, Buckets: Date Range, X-Axis: Terms, Split Chart: Date Histogram(file:kibana-visualize/agg_req,nr:9)" {
59+
t.Skip("Date range is broken, fix in progress (PR #971)")
60+
}
61+
5862
if test.TestName == "Terms with order by top metrics(file:kibana-visualize/agg_req,nr:8)" {
5963
t.Skip("Need to implement order by top metrics (talk with Jacek, he has an idea)")
6064
}

quesma/testdata/kibana-visualize/aggregation_requests.go

Lines changed: 363 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,4 +1784,367 @@ var AggregationTests = []testdata.AggregationTestCase{
17841784
WHERE "aggr__0__order_1_rank"<=13
17851785
ORDER BY "aggr__0__order_1_rank" ASC, "aggr__0__1__order_1_rank" ASC`,
17861786
},
1787+
{ // [9]
1788+
TestName: "Line, Y-axis: Min, Buckets: Date Range, X-Axis: Terms, Split Chart: Date Histogram",
1789+
QueryRequestJson: `
1790+
{
1791+
"_source": {
1792+
"excludes": []
1793+
},
1794+
"aggs": {
1795+
"2": {
1796+
"aggs": {
1797+
"3": {
1798+
"aggs": {
1799+
"1": {
1800+
"min": {
1801+
"field": "FlightDelayMin"
1802+
}
1803+
},
1804+
"4": {
1805+
"aggs": {
1806+
"1": {
1807+
"min": {
1808+
"field": "FlightDelayMin"
1809+
}
1810+
}
1811+
},
1812+
"date_histogram": {
1813+
"field": "timestamp",
1814+
"fixed_interval": "30d",
1815+
"min_doc_count": 1,
1816+
"time_zone": "Europe/Warsaw"
1817+
}
1818+
}
1819+
},
1820+
"terms": {
1821+
"field": "DistanceKilometers",
1822+
"order": {
1823+
"1": "desc"
1824+
},
1825+
"shard_size": 25,
1826+
"size": 5
1827+
}
1828+
}
1829+
},
1830+
"date_range": {
1831+
"field": "timestamp",
1832+
"ranges": [
1833+
{
1834+
"from": "now-1w/w",
1835+
"to": "now"
1836+
},
1837+
{
1838+
"from": "now-1d"
1839+
}
1840+
],
1841+
"time_zone": "Europe/Warsaw"
1842+
}
1843+
}
1844+
},
1845+
"fields": [
1846+
{
1847+
"field": "@timestamp",
1848+
"format": "date_time"
1849+
},
1850+
{
1851+
"field": "timestamp",
1852+
"format": "date_time"
1853+
}
1854+
],
1855+
"query": {
1856+
"bool": {
1857+
"filter": [
1858+
{
1859+
"range": {
1860+
"timestamp": {
1861+
"format": "strict_date_optional_time",
1862+
"gte": "2009-11-12T08:31:26.584Z",
1863+
"lte": "2024-11-12T08:31:26.584Z"
1864+
}
1865+
}
1866+
}
1867+
],
1868+
"must": [],
1869+
"must_not": [],
1870+
"should": []
1871+
}
1872+
},
1873+
"runtime_mappings": {
1874+
"hour_of_day": {
1875+
"script": {
1876+
"source": "emit(doc['timestamp'].value.getHour());"
1877+
},
1878+
"type": "long"
1879+
}
1880+
},
1881+
"script_fields": {},
1882+
"size": 0,
1883+
"stored_fields": [
1884+
"*"
1885+
],
1886+
"track_total_hits": true
1887+
}`,
1888+
ExpectedResponse: `
1889+
{
1890+
"_shards": {
1891+
"failed": 0,
1892+
"skipped": 0,
1893+
"successful": 1,
1894+
"total": 1
1895+
},
1896+
"aggregations": {
1897+
"2": {
1898+
"buckets": [
1899+
{
1900+
"3": {
1901+
"buckets": [
1902+
{
1903+
"1": {
1904+
"value": 360.0
1905+
},
1906+
"4": {
1907+
"buckets": [
1908+
{
1909+
"1": {
1910+
"value": 360.0
1911+
},
1912+
"doc_count": 1,
1913+
"key": 1728856800000,
1914+
"key_as_string": "2024-10-13T22:00:00.000"
1915+
}
1916+
]
1917+
},
1918+
"doc_count": 1,
1919+
"key": 1502.8392333984375
1920+
},
1921+
{
1922+
"1": {
1923+
"value": 360.0
1924+
},
1925+
"4": {
1926+
"buckets": [
1927+
{
1928+
"1": {
1929+
"value": 360.0
1930+
},
1931+
"doc_count": 1,
1932+
"key": 1728856800000,
1933+
"key_as_string": "2024-10-13T22:00:00.000"
1934+
}
1935+
]
1936+
},
1937+
"doc_count": 1,
1938+
"key": 2649.456787109375
1939+
},
1940+
{
1941+
"1": {
1942+
"value": 360.0
1943+
},
1944+
"4": {
1945+
"buckets": [
1946+
{
1947+
"1": {
1948+
"value": 360.0
1949+
},
1950+
"doc_count": 1,
1951+
"key": 1728856800000,
1952+
"key_as_string": "2024-10-13T22:00:00.000"
1953+
}
1954+
]
1955+
},
1956+
"doc_count": 1,
1957+
"key": 6280.2021484375
1958+
}
1959+
],
1960+
"doc_count_error_upper_bound": -1,
1961+
"sum_other_doc_count": 2666
1962+
},
1963+
"doc_count": 2671,
1964+
"from": 1730674800000.0,
1965+
"from_as_string": "2024-11-04T00:00:00.000+01:00",
1966+
"key": "2024-11-04T00:00:00.000+01:00-2024-11-12T10:15:15.067+01:00",
1967+
"to": 1731402915067.0,
1968+
"to_as_string": "2024-11-12T10:15:15.067+01:00"
1969+
},
1970+
{
1971+
"3": {
1972+
"buckets": [
1973+
{
1974+
"1": {
1975+
"value": 360.0
1976+
},
1977+
"4": {
1978+
"buckets": [
1979+
{
1980+
"1": {
1981+
"value": 360.0
1982+
},
1983+
"doc_count": 1,
1984+
"key": 1728856800000,
1985+
"key_as_string": "2024-10-13T22:00:00.000"
1986+
}
1987+
]
1988+
},
1989+
"doc_count": 1,
1990+
"key": 6287.01806640625
1991+
}
1992+
],
1993+
"doc_count_error_upper_bound": -1,
1994+
"sum_other_doc_count": 333
1995+
},
1996+
"doc_count": 338,
1997+
"from": 1731316515067.0,
1998+
"from_as_string": "2024-11-11T10:15:15.067+01:00",
1999+
"key": "2024-11-11T10:15:15.067+01:00-*"
2000+
}
2001+
]
2002+
}
2003+
},
2004+
"hits": {
2005+
"hits": [],
2006+
"max_score": null,
2007+
"total": {
2008+
"relation": "eq",
2009+
"value": 2671
2010+
}
2011+
},
2012+
"timed_out": false,
2013+
"took": 129
2014+
}`,
2015+
ExpectedPancakeResults: []model.QueryResultRow{
2016+
{Cols: []model.QueryResultCol{
2017+
model.NewQueryResultCol("aggr__2__count", int64(2671)),
2018+
model.NewQueryResultCol("aggr__2__3__parent_count", int64(2671)),
2019+
model.NewQueryResultCol("aggr__2__3__key_0", 1502.8392333984375),
2020+
model.NewQueryResultCol("aggr__2__3__count", int64(1)),
2021+
model.NewQueryResultCol("metric__2__3__1_col_0", 360.0),
2022+
model.NewQueryResultCol("aggr__2__3__4__key_0", int64(1728864000000/2592000000)),
2023+
model.NewQueryResultCol("aggr__2__3__4__count", int64(1)),
2024+
model.NewQueryResultCol("metric__2__3__4__1_col_0", 360.0),
2025+
}},
2026+
{Cols: []model.QueryResultCol{
2027+
model.NewQueryResultCol("aggr__2__count", int64(2671)),
2028+
model.NewQueryResultCol("aggr__2__3__parent_count", int64(2671)),
2029+
model.NewQueryResultCol("aggr__2__3__key_0", 2649.456787109375),
2030+
model.NewQueryResultCol("aggr__2__3__count", int64(1)),
2031+
model.NewQueryResultCol("metric__2__3__1_col_0", 360.0),
2032+
model.NewQueryResultCol("aggr__2__3__4__key_0", int64(1728864000000/2592000000)),
2033+
model.NewQueryResultCol("aggr__2__3__4__count", int64(1)),
2034+
model.NewQueryResultCol("metric__2__3__4__1_col_0", 360.0),
2035+
}},
2036+
{Cols: []model.QueryResultCol{
2037+
model.NewQueryResultCol("aggr__2__count", int64(2671)),
2038+
model.NewQueryResultCol("aggr__2__3__parent_count", int64(2671)),
2039+
model.NewQueryResultCol("aggr__2__3__key_0", 6280.2021484375),
2040+
model.NewQueryResultCol("aggr__2__3__count", int64(1)),
2041+
model.NewQueryResultCol("metric__2__3__1_col_0", 360.0),
2042+
model.NewQueryResultCol("aggr__2__3__4__key_0", int64(1728864000000/2592000000)),
2043+
model.NewQueryResultCol("aggr__2__3__4__count", int64(1)),
2044+
model.NewQueryResultCol("metric__2__3__4__1_col_0", 360.0),
2045+
}},
2046+
},
2047+
ExpectedPancakeSQL: `
2048+
SELECT "aggr__2__count", "aggr__2__3__parent_count", "aggr__2__3__key_0",
2049+
"aggr__2__3__count", "metric__2__3__1_col_0", "aggr__2__3__4__key_0",
2050+
"aggr__2__3__4__count", "metric__2__3__4__1_col_0"
2051+
FROM (
2052+
SELECT "aggr__2__count", "aggr__2__3__parent_count", "aggr__2__3__key_0",
2053+
"aggr__2__3__count", "metric__2__3__1_col_0", "aggr__2__3__4__key_0",
2054+
"aggr__2__3__4__count", "metric__2__3__4__1_col_0",
2055+
dense_rank() OVER (ORDER BY "metric__2__3__1_col_0" DESC,
2056+
"aggr__2__3__key_0" ASC) AS "aggr__2__3__order_1_rank",
2057+
dense_rank() OVER (PARTITION BY "aggr__2__3__key_0" ORDER BY
2058+
"aggr__2__3__4__key_0" ASC) AS "aggr__2__3__4__order_1_rank"
2059+
FROM (
2060+
SELECT sum(countIf(("timestamp">=toInt64(toUnixTimestamp(toStartOfWeek(
2061+
subDate(now(), INTERVAL 1 week)))) AND "timestamp"<toInt64(toUnixTimestamp
2062+
(now()))))) OVER () AS "aggr__2__count",
2063+
sum(countIf(("timestamp">=toInt64(toUnixTimestamp(toStartOfWeek(subDate(
2064+
now(), INTERVAL 1 week)))) AND "timestamp"<toInt64(toUnixTimestamp(now()))
2065+
))) OVER () AS "aggr__2__3__parent_count",
2066+
"DistanceKilometers" AS "aggr__2__3__key_0",
2067+
sum(countIf(("timestamp">=toInt64(toUnixTimestamp(toStartOfWeek(subDate(
2068+
now(), INTERVAL 1 week)))) AND "timestamp"<toInt64(toUnixTimestamp(now()))
2069+
))) OVER (PARTITION BY "aggr__2__3__key_0") AS "aggr__2__3__count",
2070+
minOrNull(minOrNullIf("FlightDelayMin", ("timestamp">=toInt64(
2071+
toUnixTimestamp(toStartOfWeek(subDate(now(), INTERVAL 1 week)))) AND
2072+
"timestamp"<toInt64(toUnixTimestamp(now()))))) OVER (PARTITION BY
2073+
"aggr__2__3__key_0") AS "metric__2__3__1_col_0",
2074+
toInt64((toUnixTimestamp64Milli("timestamp")+timeZoneOffset(toTimezone(
2075+
"timestamp", 'Europe/Warsaw'))*1000) / 2592000000) AS
2076+
"aggr__2__3__4__key_0",
2077+
countIf(("timestamp">=toInt64(toUnixTimestamp(toStartOfWeek(subDate(now(),
2078+
INTERVAL 1 week)))) AND "timestamp"<toInt64(toUnixTimestamp(now())))) AS
2079+
"aggr__2__3__4__count",
2080+
minOrNullIf("FlightDelayMin", ("timestamp">=toInt64(toUnixTimestamp(
2081+
toStartOfWeek(subDate(now(), INTERVAL 1 week)))) AND "timestamp"<toInt64(
2082+
toUnixTimestamp(now())))) AS "metric__2__3__4__1_col_0"
2083+
FROM __quesma_table_name
2084+
WHERE (("timestamp">=fromUnixTimestamp64Milli(1258014686584) AND "timestamp"
2085+
<=fromUnixTimestamp64Milli(1731400286584)) AND ("timestamp">=toInt64(
2086+
toUnixTimestamp(toStartOfWeek(subDate(now(), INTERVAL 1 week)))) AND
2087+
"timestamp"<toInt64(toUnixTimestamp(now()))))
2088+
GROUP BY "DistanceKilometers" AS "aggr__2__3__key_0",
2089+
toInt64((toUnixTimestamp64Milli("timestamp")+timeZoneOffset(toTimezone(
2090+
"timestamp", 'Europe/Warsaw'))*1000) / 2592000000) AS
2091+
"aggr__2__3__4__key_0"))
2092+
WHERE "aggr__2__3__order_1_rank"<=6
2093+
ORDER BY "aggr__2__3__order_1_rank" ASC, "aggr__2__3__4__order_1_rank" ASC`,
2094+
ExpectedAdditionalPancakeSQLs: []string{`
2095+
SELECT "aggr__2__count", "aggr__2__3__parent_count", "aggr__2__3__key_0",
2096+
"aggr__2__3__count", "metric__2__3__1_col_0", "aggr__2__3__4__key_0",
2097+
"aggr__2__3__4__count", "metric__2__3__4__1_col_0"
2098+
FROM (
2099+
SELECT "aggr__2__count", "aggr__2__3__parent_count", "aggr__2__3__key_0",
2100+
"aggr__2__3__count", "metric__2__3__1_col_0", "aggr__2__3__4__key_0",
2101+
"aggr__2__3__4__count", "metric__2__3__4__1_col_0",
2102+
dense_rank() OVER (ORDER BY "metric__2__3__1_col_0" DESC,
2103+
"aggr__2__3__key_0" ASC) AS "aggr__2__3__order_1_rank",
2104+
dense_rank() OVER (PARTITION BY "aggr__2__3__key_0" ORDER BY
2105+
"aggr__2__3__4__key_0" ASC) AS "aggr__2__3__4__order_1_rank"
2106+
FROM (
2107+
SELECT sum(countIf("timestamp">=toInt64(toUnixTimestamp(subDate(now(),
2108+
INTERVAL 1 day))))) OVER () AS "aggr__2__count",
2109+
sum(countIf("timestamp">=toInt64(toUnixTimestamp(subDate(now(), INTERVAL 1
2110+
day))))) OVER () AS "aggr__2__3__parent_count",
2111+
"DistanceKilometers" AS "aggr__2__3__key_0",
2112+
sum(countIf("timestamp">=toInt64(toUnixTimestamp(subDate(now(), INTERVAL 1
2113+
day))))) OVER (PARTITION BY "aggr__2__3__key_0") AS "aggr__2__3__count",
2114+
minOrNull(minOrNullIf("FlightDelayMin", "timestamp">=toInt64(
2115+
toUnixTimestamp(subDate(now(), INTERVAL 1 day))))) OVER (PARTITION BY
2116+
"aggr__2__3__key_0") AS "metric__2__3__1_col_0",
2117+
toInt64((toUnixTimestamp64Milli("timestamp")+timeZoneOffset(toTimezone(
2118+
"timestamp", 'Europe/Warsaw'))*1000) / 2592000000) AS
2119+
"aggr__2__3__4__key_0",
2120+
countIf("timestamp">=toInt64(toUnixTimestamp(subDate(now(), INTERVAL 1 day
2121+
)))) AS "aggr__2__3__4__count",
2122+
minOrNullIf("FlightDelayMin", "timestamp">=toInt64(toUnixTimestamp(subDate
2123+
(now(), INTERVAL 1 day)))) AS "metric__2__3__4__1_col_0"
2124+
FROM __quesma_table_name
2125+
WHERE (("timestamp">=fromUnixTimestamp64Milli(1258014686584) AND "timestamp"
2126+
<=fromUnixTimestamp64Milli(1731400286584)) AND "timestamp">=toInt64(
2127+
toUnixTimestamp(subDate(now(), INTERVAL 1 day))))
2128+
GROUP BY "DistanceKilometers" AS "aggr__2__3__key_0",
2129+
toInt64((toUnixTimestamp64Milli("timestamp")+timeZoneOffset(toTimezone(
2130+
"timestamp", 'Europe/Warsaw'))*1000) / 2592000000) AS
2131+
"aggr__2__3__4__key_0"))
2132+
WHERE "aggr__2__3__order_1_rank"<=6
2133+
ORDER BY "aggr__2__3__order_1_rank" ASC, "aggr__2__3__4__order_1_rank" ASC`,
2134+
},
2135+
ExpectedAdditionalPancakeResults: [][]model.QueryResultRow{
2136+
{
2137+
{Cols: []model.QueryResultCol{
2138+
model.NewQueryResultCol("aggr__2__count", int64(2671)),
2139+
model.NewQueryResultCol("aggr__2__3__parent_count", int64(338)),
2140+
model.NewQueryResultCol("aggr__2__3__key_0", 6287.01806640625),
2141+
model.NewQueryResultCol("aggr__2__3__count", int64(1)),
2142+
model.NewQueryResultCol("metric__2__3__1_col_0", 360.0),
2143+
model.NewQueryResultCol("aggr__2__3__4__key_0", int64(1728864000000/2592000000)),
2144+
model.NewQueryResultCol("aggr__2__3__4__count", int64(1)),
2145+
model.NewQueryResultCol("metric__2__3__4__1_col_0", 360.0),
2146+
}},
2147+
},
2148+
},
2149+
},
17872150
}

0 commit comments

Comments
 (0)