use of com.facebook.presto.verifier.framework.LimitQueryDeterminismAnalysis.FAILED_DATA_CHANGED in project presto by prestodb.
the class LimitQueryDeterminismAnalyzer method analyzeLimitNoOrderBy.
private LimitQueryDeterminismAnalysis analyzeLimitNoOrderBy(Query newLimitQuery, long limit) {
Query rowCountQuery = simpleQuery(new Select(false, ImmutableList.of(new SingleColumn(new FunctionCall(QualifiedName.of("count"), ImmutableList.of(new LongLiteral("1")))))), new TableSubquery(newLimitQuery));
QueryResult<Long> result = callAndConsume(() -> prestoAction.execute(rowCountQuery, DETERMINISM_ANALYSIS_MAIN, resultSet -> Optional.of(resultSet.getLong(1))), stats -> stats.getQueryStats().map(QueryStats::getQueryId).ifPresent(determinismAnalysisDetails::setLimitQueryAnalysisQueryId));
long rowCountHigherLimit = getOnlyElement(result.getResults());
if (rowCountHigherLimit == rowCount) {
return DETERMINISTIC;
}
if (rowCountHigherLimit > rowCount) {
return NON_DETERMINISTIC;
}
return FAILED_DATA_CHANGED;
}
Aggregations