Skip to content

Commit

Permalink
PR stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-mclawhorn committed Mar 2, 2017
1 parent 5473dd2 commit fce490b
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public ResponseException(
* @param statusType Status type of the response
* @param druidQuery The druid query being processed
* @param error Exception object with error details
*
* @deprecated In order to ensure correct serialization of the Druid Query, an ObjectWriter with all appropriate
* configuration should be passed in to the constructor
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public class DruidResponseParser {
* @param jsonResult Druid results in json
* @param schema Schema for results
* @param queryType the type of query, note that this implementation only supports instances of
* @param dateTimeZone the time zone used for format the results
* {@link DefaultQueryType}
* @param dateTimeZone the time zone used for format the results
*
* @return the set of results
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,7 @@ private ResultSetSchema getResultSetSchema(JsonNode schemaNode) {
.collect(Collectors.toSet())
);

return new ResultSetSchema(
generateGranularity(schemaNode.get(SCHEMA_GRANULARITY).asText(), timezone), columns
);
return new ResultSetSchema(generateGranularity(schemaNode.get(SCHEMA_GRANULARITY).asText(), timezone), columns);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import com.yahoo.bard.webservice.data.Result;
import com.yahoo.bard.webservice.data.ResultSet;
import com.yahoo.bard.webservice.data.ResultSetSchema;
import com.yahoo.bard.webservice.druid.model.orderby.SortDirection;
import com.yahoo.bard.webservice.logging.RequestLog;
import com.yahoo.bard.webservice.table.Schema;

import org.joda.time.DateTime;

Expand Down Expand Up @@ -59,26 +59,26 @@ public ResultSet map(ResultSet resultSet) {
Comparator.reverseOrder());

return new ResultSet(
resultSet.getSchema(),
dateTimeList.stream()
.map(bucketizedResultsMap::get)
.flatMap(List::stream)
.collect(Collectors.toList()),
resultSet.getSchema()
.collect(Collectors.toList())
);
} finally {
RequestLog.stopTiming("sortResultSet");
}
}

@Override
protected Result map(Result result, Schema schema) {
protected Result map(Result result, ResultSetSchema schema) {
//Not needed, because this mapper overrides map(ResultSet). So it is just a no-op.
return result;
}


@Override
protected Schema map(Schema schema) {
protected ResultSetSchema map(ResultSetSchema schema) {
//Because this method is not necessary, it just returns the schema unchanged.
return schema;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected Result map(Result result, ResultSetSchema schema) {
}

MetricColumn metricColumn = schema.<MetricColumn>getColumn(columnName, MetricColumn.class).orElseThrow(
() -> new IllegalStateException("Unexpected missing column")
() -> new IllegalStateException("Unexpected missing column: " + columnName)
);

BigDecimal value = result.getMetricValueAsNumber(metricColumn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ public void resetColumns(SegmentMetadata segmentMetadata, DimensionDictionary di
Map<String, Set<Interval>> metricIntervals = segmentMetadata.getMetricIntervals();
setAvailability(new ImmutableAvailability(
name,
schema,
dimensionIntervals,
metricIntervals,
dimensionDictionary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.yahoo.bard.webservice.data.dimension.DimensionDictionary;
import com.yahoo.bard.webservice.data.metric.MetricColumn;
import com.yahoo.bard.webservice.table.Column;
import com.yahoo.bard.webservice.table.PhysicalTableSchema;
import com.yahoo.bard.webservice.util.SimplifiedIntervalList;

import com.google.common.collect.ImmutableMap;
Expand Down Expand Up @@ -73,14 +72,12 @@ public ImmutableAvailability(
* Constructor.
*
* @param tableName The name of the data source associated with this ImmutableAvailability
* @param schema The schema for the availabilities
* @param dimensionIntervals The dimension availability map by dimension name
* @param metricIntervals The metric availability map
* @param dimensionDictionary The dictionary to resolve dimension names against
*/
public ImmutableAvailability(
String tableName,
PhysicalTableSchema schema,
Map<String, Set<Interval>> dimensionIntervals,
Map<String, Set<Interval>> metricIntervals,
DimensionDictionary dimensionDictionary
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Licensed under the terms of the Apache license. Please see LICENSE.md file distributed with this work for terms.
package com.yahoo.bard.webservice.table.resolver;

import com.yahoo.bard.webservice.table.PhysicalTable;
import com.yahoo.bard.webservice.config.BardFeatureFlag;
import com.yahoo.bard.webservice.data.PartialDataHandler;
import com.yahoo.bard.webservice.data.metric.TemplateDruidQuery;
import com.yahoo.bard.webservice.data.volatility.VolatileIntervalsService;
import com.yahoo.bard.webservice.table.PhysicalTable;
import com.yahoo.bard.webservice.util.ChainingComparator;
import com.yahoo.bard.webservice.web.DataApiRequest;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Licensed under the terms of the Apache license. Please see LICENSE.md file distributed with this work for terms.
package com.yahoo.bard.webservice.table.resolver;

import com.yahoo.bard.webservice.table.PhysicalTable;
import com.yahoo.bard.webservice.data.PartialDataHandler;
import com.yahoo.bard.webservice.data.metric.TemplateDruidQuery;
import com.yahoo.bard.webservice.table.PhysicalTable;
import com.yahoo.bard.webservice.util.IntervalUtils;
import com.yahoo.bard.webservice.util.SimplifiedIntervalList;
import com.yahoo.bard.webservice.web.DataApiRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Licensed under the terms of the Apache license. Please see LICENSE.md file distributed with this work for terms.
package com.yahoo.bard.webservice.table.resolver;

import com.yahoo.bard.webservice.table.PhysicalTable;
import com.yahoo.bard.webservice.data.metric.TemplateDruidQuery;
import com.yahoo.bard.webservice.table.PhysicalTable;
import com.yahoo.bard.webservice.web.DataApiRequest;

import java.util.Collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

import static com.yahoo.bard.webservice.web.ErrorMessageFormat.TABLE_SCHEMA_UNDEFINED;

import com.yahoo.bard.webservice.table.PhysicalTable;
import com.yahoo.bard.webservice.data.dimension.Dimension;
import com.yahoo.bard.webservice.data.metric.LogicalMetric;
import com.yahoo.bard.webservice.data.metric.TemplateDruidQuery;
import com.yahoo.bard.webservice.druid.model.query.Granularity;
import com.yahoo.bard.webservice.table.Column;
import com.yahoo.bard.webservice.table.PhysicalTable;
import com.yahoo.bard.webservice.util.TableUtils;
import com.yahoo.bard.webservice.web.DataApiRequest;
import com.yahoo.bard.webservice.web.ErrorMessageFormat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ public enum ErrorMessageFormat implements MessageFormatter {
"Failed to retrieve data.",
"Received %s with status code %s for reason %s when sending %s to Druid"
),

RESULT_MAPPING_FAILURE(
"Error occurred while processing response data: %s"
)
;

private final String messageFormat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// 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.responseprocessors;

import static com.yahoo.bard.webservice.web.ErrorMessageFormat.RESULT_MAPPING_FAILURE;
import static com.yahoo.bard.webservice.web.responseprocessors.ResponseContextKeys.API_METRIC_COLUMN_NAMES;
import static com.yahoo.bard.webservice.web.responseprocessors.ResponseContextKeys.HEADERS;
import static com.yahoo.bard.webservice.web.responseprocessors.ResponseContextKeys.REQUESTED_API_DIMENSION_FIELDS;
Expand Down Expand Up @@ -123,6 +124,14 @@ public void processResponse(JsonNode json, DruidAggregationQuery<?> druidQuery,
invalidPage,
getObjectMappers().getMapper().writer()
));
} catch (IllegalStateException ise) {
LOG.error(RESULT_MAPPING_FAILURE.logFormat(ise.getMessage()));
responseEmitter.onError(new ResponseException(
Status.INTERNAL_SERVER_ERROR,
druidQuery,
new Exception(RESULT_MAPPING_FAILURE.format(ise.getMessage())),
getObjectMappers().getMapper().writer()
));
} catch (Exception exception) {
LOG.error("Exception processing druid call in success", exception);
responseEmitter.onError(new ResponseException(
Expand Down

0 comments on commit fce490b

Please sign in to comment.