Search in sources :

Example 6 with QueryStats

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);
}
Also used : PARSING_OPTIONS(com.facebook.presto.verifier.framework.VerifierUtil.PARSING_OPTIONS) QueryStats(com.facebook.presto.jdbc.QueryStats) Statement(com.facebook.presto.sql.tree.Statement) ParsingException(com.facebook.presto.sql.parser.ParsingException)

Example 7 with QueryStats

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()));
}
Also used : ChecksumResult(com.facebook.presto.verifier.checksum.ChecksumResult) Query(com.facebook.presto.sql.tree.Query) QueryStats(com.facebook.presto.jdbc.QueryStats)

Aggregations

QueryStats (com.facebook.presto.jdbc.QueryStats)7 Statement (com.facebook.presto.sql.tree.Statement)4 List (java.util.List)4 Query (com.facebook.presto.sql.tree.Query)3 PrestoAction (com.facebook.presto.verifier.prestoaction.PrestoAction)3 Iterables.getOnlyElement (com.google.common.collect.Iterables.getOnlyElement)3 Map (java.util.Map)3 Objects.requireNonNull (java.util.Objects.requireNonNull)3 Optional (java.util.Optional)3 LongLiteral (com.facebook.presto.sql.tree.LongLiteral)2 DeterminismAnalysisDetails (com.facebook.presto.verifier.event.DeterminismAnalysisDetails)2 DETERMINISM_ANALYSIS_MAIN (com.facebook.presto.verifier.framework.QueryStage.DETERMINISM_ANALYSIS_MAIN)2 VerifierUtil.callAndConsume (com.facebook.presto.verifier.framework.VerifierUtil.callAndConsume)2 Preconditions.checkState (com.google.common.base.Preconditions.checkState)2 ImmutableList (com.google.common.collect.ImmutableList)2 String.format (java.lang.String.format)2 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)2 Set (java.util.Set)2 Logger (com.facebook.airlift.log.Logger)1