Slackbot
02/08/2023, 8:27 PMSamarth Jain
02/08/2023, 8:30 PMSELECT COUNT(*) as total,
SUM(impressions) AS impressions
FROM (
SELECT dim1,
dim2 SUM(impressions) AS impressions (
(SUM(some_metric) * 1.0) / SUM(impressions)
) AS takeRate ---notice the alias here
FROM druid_datasource
WHERE date BETWEEN '20230203' AND '20230203'
AND country_desc IN ('Algeria')
GROUP BY 1,
2
HAVING takeRate BETWEEN 0 AND 1 ---notice the usage of alias in having clause
)
WHERE impressions BETWEEN 1000 AND 2000Samarth Jain
02/08/2023, 8:32 PM"postAggregations": [],
"having": {
"type": "filter",
"filter": {
"type": "and",
"fields": [{
"type": "expression",
"expression": "(((\"a1\" * 1.0) / \"a0\") >= 0)"
}, {
"type": "expression",
"expression": "(((\"a1\" * 1.0) / \"a0\") <= 1)"
}]
},
"finalize": true
},
"limitSpec": {
"type": "NoopLimitSpec"
},Samarth Jain
02/08/2023, 8:34 PM"postAggregations": [],
"having": null,
"limitSpec": {
"type": "NoopLimitSpec"
}
Instead, what I noticed was that the having clause was re-written to a where clause in the outer query.
"filter": {
"type": "and",
"fields": [{
"type": "bound",
"dimension": "impressions",
"lower": "1000",
"upper": "2000",
"lowerStrict": false,
"upperStrict": false,
"extractionFn": null,
"ordering": {
"type": "numeric"
}
}, {
"type": "bound",
"dimension": "v0",
"lower": "0",
"upper": "1",
"lowerStrict": false,
"upperStrict": false,
"extractionFn": null,
"ordering": {
"type": "numeric"
}
}]
}Samarth Jain
02/08/2023, 8:35 PMVadim
02/08/2023, 8:47 PMVadim
02/08/2023, 8:48 PMsmart query limit toggle tells me that you are on an older version of Druid. In today's Druid it was renamed to "Limit inline results" and it is a checkbox nowVadim
02/08/2023, 8:49 PMVadim
02/08/2023, 8:54 PMSamarth Jain
02/08/2023, 9:24 PMSamarth Jain
02/08/2023, 9:25 PMVadim
02/08/2023, 10:57 PMVadim
02/08/2023, 10:58 PM