/** * Add a logical metric to the dictionary. * * @param logicalMetric Logical metric to add * * @return True if the Logical Metric did not exist in the dictionary before, false if it did */ public boolean add(LogicalMetric logicalMetric) { return this.put(logicalMetric.getName(), logicalMetric) == null; }
/** * Constructor. * * @param metric a LogicalMetric * @param direction sort direction * * Note: Plan is to remove this LogicalMetric based constructor and have a DruidColumn based constructor. */ public OrderByColumn(LogicalMetric metric, SortDirection direction) { this.dimension = metric.getName(); this.direction = direction; }
public MetricField getMetricField() { return getTemplateDruidQuery().getMetricField(getName()); }
@Override protected LogicalMetric makeInner(LogicalMetricInfo logicalMetricInfo, List<String> dependentMetrics) { // Get the Metric that is being averaged over LogicalMetric dependentMetric = metrics.get(dependentMetrics.get(0)); // Get the field being subtotalled in the inner query MetricField sourceMetric = convertToSketchEstimateIfNeeded(dependentMetric.getMetricField()); // Build the TemplateDruidQuery for the metric TemplateDruidQuery innerQuery = buildInnerQuery(sourceMetric, dependentMetric.getTemplateDruidQuery()); TemplateDruidQuery outerQuery = buildOuterQuery(logicalMetricInfo.getName(), sourceMetric, innerQuery); return new LogicalMetric(outerQuery, NO_OP_MAPPER, logicalMetricInfo); }
@Override protected LogicalMetric makeInner(LogicalMetricInfo logicalMetricInfo, List<String> dependentMetrics) { TemplateDruidQuery query = new TemplateDruidQuery( Collections.singleton(new CountAggregation(logicalMetricInfo.getName())), Collections.emptySet() ); return new LogicalMetric(query, NO_OP_MAPPER, logicalMetricInfo); }
/** * Makes a copy of the template query, changing nested query. * <p> * Everything is a shallow copy. * * @param newNestedQuery The nestedQuery to replace in the copy * * @return copy of the query */ public TemplateDruidQuery withInnerQuery(TemplateDruidQuery newNestedQuery) { return new TemplateDruidQuery(aggregations, postAggregations, newNestedQuery, timeGrain); }
@Override protected LogicalMetric makeInner(LogicalMetricInfo logicalMetricInfo, List<String> dependentMetrics) { return new LogicalMetric( null, ROW_NUM_MAPPER, logicalMetricInfo ); }
@Override public String toString() { return "LogicalMetric{\n" + "name=" + logicalMetricInfo.getName() + ",\n" + "templateDruidQuery=" + query + ",\n" + "calculation=" + calculation + "\n" + "}"; }
/** * Checks if the template druid query is nested. * * @return true if query is nested else false. */ public boolean isNested() { return (depth() > 1); }
@Override protected MetricDictionary factory(MetricDictionary scope) { return new MetricDictionary(scope); } }
@Override public String toString() { return "{metric:'" + getName() + "'}"; } }
@Override public String toString() { return "{logicalMetric:'" + getName() + "'}"; } }
public String getCategory() { return logicalMetricInfo.getCategory(); }
public String getDescription() { return logicalMetricInfo.getDescription(); }
/** * Makes a copy of the template query and any sub query(s), changing post-aggregations. * <p> * Everything is a shallow copy. * * @param newPostAggregations The PostAggregations to replace with in the copy * * @return copy of the query */ public TemplateDruidQuery withPostAggregations(Collection<PostAggregation> newPostAggregations) { return new TemplateDruidQuery(aggregations, newPostAggregations, nestedQuery, timeGrain); }
public String getMetricName() { return logicalMetricInfo.getName(); }
/** * Constructor. * * @param metric The logical metric */ public LogicalMetricColumn(LogicalMetric metric) { super(metric.getName()); this.metric = metric; }
/** * Makes a copy of the template query and any sub query(s), changing time grain on the outermost level only. * <p> * Everything is a shallow copy. * * @param newTimeGrain The TimeGrain to replace with in the copy * * @return copy of the query */ public TemplateDruidQuery withGranularity(ZonelessTimeGrain newTimeGrain) { return new TemplateDruidQuery(aggregations, postAggregations, nestedQuery, newTimeGrain); }
public String getName() { return logicalMetricInfo.getName(); }
/** * Makes a copy of the template query and any sub query(s), changing aggregations. * <p> * Everything is a shallow copy. * * @param newAggregations The Aggregations to replace in the copy * * @return copy of the query */ @Override public TemplateDruidQuery withAggregations(Collection<Aggregation> newAggregations) { return new TemplateDruidQuery(newAggregations, postAggregations, nestedQuery, timeGrain); }