use of parsii.tokenizer.ParseException in project pinot by linkedin.
the class MetricExpression method computeMetricFunctions.
public List<MetricFunction> computeMetricFunctions() {
try {
Scope scope = Scope.create();
Set<String> metricNames = new TreeSet<>();
// expression parser errors out on variables starting with _
// we're replacing the __COUNT default metric, with an escaped string
// after evaluating, we replace the escaped string back with the original
String modifiedExpressions = expression.replace(COUNT_METRIC, COUNT_METRIC_ESCAPED);
Parser.parse(modifiedExpressions, scope);
metricNames = scope.getLocalNames();
ArrayList<MetricFunction> metricFunctions = new ArrayList<>();
for (String metricName : metricNames) {
if (metricName.equals(COUNT_METRIC_ESCAPED)) {
metricName = COUNT_METRIC;
}
metricFunctions.add(new MetricFunction(aggFunction, metricName));
}
return metricFunctions;
} catch (ParseException e) {
throw new RuntimeException("Exception parsing expressionString:" + expression, e);
}
}
Aggregations