use of com.facebook.presto.jdbc.QueryStats in project presto by prestodb.
the class DdlVerification method verify.
@Override
@SuppressWarnings("unchecked")
protected DdlMatchResult verify(QueryObjectBundle control, QueryObjectBundle test, Optional<QueryResult<Void>> controlQueryResult, Optional<QueryResult<Void>> testQueryResult, ChecksumQueryContext controlChecksumQueryContext, ChecksumQueryContext testChecksumQueryContext) {
Statement controlChecksumQuery = getChecksumQuery(control);
Statement testChecksumQuery = getChecksumQuery(test);
controlChecksumQueryContext.setChecksumQuery(formatSql(controlChecksumQuery));
testChecksumQueryContext.setChecksumQuery(formatSql(testChecksumQuery));
String controlChecksum = getOnlyElement(callAndConsume(() -> getHelperAction().execute(controlChecksumQuery, CONTROL_CHECKSUM, checksumConverter), stats -> stats.getQueryStats().map(QueryStats::getQueryId).ifPresent(controlChecksumQueryContext::setChecksumQueryId)).getResults());
String testChecksum = getOnlyElement(callAndConsume(() -> getHelperAction().execute(testChecksumQuery, TEST_CHECKSUM, checksumConverter), stats -> stats.getQueryStats().map(QueryStats::getQueryId).ifPresent(testChecksumQueryContext::setChecksumQueryId)).getResults());
S controlObject;
S testObject;
try {
controlObject = (S) sqlParser.createStatement(controlChecksum, PARSING_OPTIONS);
} catch (ParsingException e) {
return new DdlMatchResult(CONTROL_NOT_PARSABLE, Optional.of(e), controlChecksum, testChecksum);
}
try {
testObject = (S) sqlParser.createStatement(testChecksum, PARSING_OPTIONS);
} catch (ParsingException e) {
return new DdlMatchResult(TEST_NOT_PARSABLE, Optional.of(e), controlChecksum, testChecksum);
}
return new DdlMatchResult(match(controlObject, testObject, control, test) ? MATCH : MISMATCH, Optional.empty(), controlChecksum, testChecksum);
}
use of com.facebook.presto.jdbc.QueryStats in project presto by prestodb.
the class DataVerification method verify.
@Override
public DataMatchResult verify(QueryObjectBundle control, QueryObjectBundle test, Optional<QueryResult<Void>> controlQueryResult, Optional<QueryResult<Void>> testQueryResult, ChecksumQueryContext controlChecksumQueryContext, ChecksumQueryContext testChecksumQueryContext) {
List<Column> controlColumns = getColumns(getHelperAction(), typeManager, control.getObjectName());
List<Column> testColumns = getColumns(getHelperAction(), typeManager, test.getObjectName());
Query controlChecksumQuery = checksumValidator.generateChecksumQuery(control.getObjectName(), controlColumns);
Query testChecksumQuery = checksumValidator.generateChecksumQuery(test.getObjectName(), testColumns);
controlChecksumQueryContext.setChecksumQuery(formatSql(controlChecksumQuery));
testChecksumQueryContext.setChecksumQuery(formatSql(testChecksumQuery));
QueryResult<ChecksumResult> controlChecksum = callAndConsume(() -> getHelperAction().execute(controlChecksumQuery, CONTROL_CHECKSUM, ChecksumResult::fromResultSet), stats -> stats.getQueryStats().map(QueryStats::getQueryId).ifPresent(controlChecksumQueryContext::setChecksumQueryId));
QueryResult<ChecksumResult> testChecksum = callAndConsume(() -> getHelperAction().execute(testChecksumQuery, TEST_CHECKSUM, ChecksumResult::fromResultSet), stats -> stats.getQueryStats().map(QueryStats::getQueryId).ifPresent(testChecksumQueryContext::setChecksumQueryId));
return match(checksumValidator, controlColumns, testColumns, getOnlyElement(controlChecksum.getResults()), getOnlyElement(testChecksum.getResults()));
}
Aggregations