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

Support custom Druid queries. #57

Merged
merged 1 commit into from
Oct 6, 2016
Merged

Conversation

archolewa
Copy link
Contributor

--QueryType has been turned into an interface backed by an enum.

--The DruidResponseParser and DruidQueryBuilder are now injectable.

List<Result> results;
switch (queryType) {
List<Result> results = null;
switch (defaultQueryType) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "missing" break is in the default case.

@michael-mclawhorn
Copy link
Contributor

Do we want to make a test on DruidResponseParserSpec to exercise the unsupported operation exception on a non enum instance of the query type interface.

Copy link
Collaborator

@cdeszaq cdeszaq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few small things

- [Fili now supports custom Druid query types](https://github.com/yahoo/fili/pull/57)
* `QueryType` has been turned into an interface, backed by an enum `DefaultQueryType`.
* `DruidResponseParser` is now injectable by overriding `AbstractBinderFactory::buildDruidResponseParser` method.
* `DruidQueryBuilder` is now injectable by overriding `AbstractBinderFactory::buildDruidQueryBuilder` method.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't this already overridable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/* Get dimension and metric columns */
Set<DimensionColumn> dimensionColumns = schema.getColumns(DimensionColumn.class);
Set<MetricColumn> metricColumns = schema.getColumns(MetricColumn.class);

List<Result> results;
switch (queryType) {
List<Result> results = null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? It defaults to null

Copy link
Contributor Author

@archolewa archolewa Oct 3, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's needed to make the java compiler happy. Otherwise, it complains that results may not have been initialized. Likely because it doesn't realize that the default case throws an exception, now that the exception throwing is hidden behind a method.

*
* @return the set of results
*/
public ResultSet parse(JsonNode jsonResult, ZonedSchema schema, QueryType queryType) {

LOG.trace("Parsing druid query {} by json result: {} using schema: {}", queryType, jsonResult, schema);


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra whitespace not needed

@@ -114,7 +115,12 @@ public void postDruidQuery(
}

// Set the response to use based on the type of the query we're processing
switch (lastQuery.getQueryType()) {
if (!(lastQuery.getQueryType() instanceof DefaultQueryType)) {
throw new IllegalArgumentException("Illegal query type : " + lastQuery.getQueryType());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a note (likely to the changelog) that this test extension point doesn't support new types of queries.


if (!(queryType instanceof DefaultQueryType)) {
// Throw an exception for unsupported query types
unsupportedQueryType(queryType);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a note (likely to the changelog) that this test extension point doesn't support new types of queries.

postAggregations = Collections.<PostAggregation>singletonList(new ConstantPostAggregation("count", weight));
postAggregations = Collections.singletonList(new ConstantPostAggregation("count", weight));

if (!(innerQuery.getQueryType() instanceof DefaultQueryType)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a note (likely to the changelog) that this test extension point doesn't support new types of queries.

@archolewa archolewa force-pushed the support-custom-query-types branch from 1aad05f to 37e2030 Compare October 5, 2016 14:41
Copy link
Collaborator

@cdeszaq cdeszaq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@michael-mclawhorn
Copy link
Contributor

👍

--`QueryType` has been turned into an interface backed by an enum.

--The `DruidResponseParser` and `DruidQueryBuilder` are now injectable.
@archolewa archolewa force-pushed the support-custom-query-types branch from 37e2030 to 463d267 Compare October 5, 2016 19:07
@archolewa archolewa merged commit bae3fb3 into master Oct 6, 2016
@archolewa archolewa deleted the support-custom-query-types branch October 6, 2016 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants