Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

having should be null to inner queries #614

Merged
merged 3 commits into from
Jan 18, 2018
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ Current

### Fixed:

- [Having clause was nesting inward on nested queries resulting in rows that didn't exist being referenced](https://github.com/yahoo/fili/pull/614/files)

- [Scoped metric dictionaries and the having clause now work together by default](https://github.com/yahoo/fili/pull/580)
* Add a new ApiHavingGenerator that builds a temporary metric dictionary from the set of requested metrics(not from globally scoped metric dictionary), and then using those to resolve the having clause.
* Add a table generating functions in BaseTableLoader that effectively allow the customer to provide a different metric dictionary at lower scope(not from the globally scoped metric dictionary) for use when building each table.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,15 @@ protected GroupByQuery buildGroupByQuery(
} else {
LOG.trace("Building a multi pass druid groupBy query");
// Build the inner query without an order by, since we only want to do that at the top level
// Sorts don't apply to inner queries and Filters only apply to the innermost query
// Sorts and Having don't apply to inner queries and Filters only apply to the innermost query
GroupByQuery query = buildGroupByQuery(
template.getInnerQuery().get(),
table,
mergedGranularity,
timeZone,
groupByDimensions,
mergedFilter,
having,
(Having) null,
intervals,
(LimitSpec) null
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// Copyright 2017 Yahoo Inc.
// Licensed under the terms of the Apache license. Please see LICENSE.md file distributed with this work for terms.
package com.yahoo.bard.webservice.web.endpoints

// Ensure that having only applies to the outer query when nesting
class DailyAvgWeekWithHavingSpec extends DailyAvgWeekSpec {

@Override
Map<String, List<String>> getQueryParams() {
[
"metrics": ["dayAvgUsers"],
"dateTime": ["2014-09-01%2F2014-09-08"],
"having": ["dayAvgUsers-gt[3]"]
]
}

@Override
String getExpectedDruidQuery() {
"""{
"aggregations": [
{
"fieldName": "one",
"name": "count",
"type": "longSum"
},
{
"fieldName": "users_estimate",
"name": "users_estimate_sum",
"type": "doubleSum"
}
],
"dataSource": {
"query": {
"aggregations": [
{
"fieldName": "users",
"name": "users",
"size": 16384,
"type": "sketchMerge"
}
],
"dataSource": {
"name": "color_shapes",
"type": "table"
},
"dimensions": ["color"],
"granularity": ${getTimeGrainString()},
"intervals": ["2014-09-01T00:00:00.000Z/2014-09-08T00:00:00.000Z"],
"postAggregations": [
{
"field": {
"fieldName": "users",
"type": "fieldAccess"
},
"name": "users_estimate",
"type": "sketchEstimate"
},
{
"name": "one",
"type": "constant",
"value": 1.0
}
],
"queryType": "groupBy",
"context": {}
},
"type": "query"
},
"dimensions": ["color"],
"granularity": ${getTimeGrainString("week")},
"having":{"aggregation":"dayAvgUsers","type":"greaterThan","value":3.0},
"intervals": ["2014-09-01T00:00:00.000Z/2014-09-08T00:00:00.000Z"],
"postAggregations": [
{
"fields": [
{
"fieldName": "users_estimate_sum",
"type": "fieldAccess"
},
{
"fieldName": "count",
"type": "fieldAccess"
}
],
"fn": "/",
"name": "dayAvgUsers",
"type": "arithmetic"
}
],
"queryType": "groupBy",
"context": {}
}"""
}
}