Search in sources :

Example 1 with PARSING_OPTIONS

use of com.facebook.presto.verifier.framework.VerifierUtil.PARSING_OPTIONS 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)

Aggregations

QueryStats (com.facebook.presto.jdbc.QueryStats)1 ParsingException (com.facebook.presto.sql.parser.ParsingException)1 Statement (com.facebook.presto.sql.tree.Statement)1 PARSING_OPTIONS (com.facebook.presto.verifier.framework.VerifierUtil.PARSING_OPTIONS)1