Search in sources :

Example 1 with FailureResolverFactoryContext

use of com.facebook.presto.verifier.resolver.FailureResolverFactoryContext in project presto by prestodb.

the class VerificationFactory method get.

public Verification get(SourceQuery sourceQuery, Optional<VerificationContext> existingContext) {
    QueryType queryType = QueryType.of(sqlParser.createStatement(sourceQuery.getQuery(CONTROL), PARSING_OPTIONS));
    VerificationContext verificationContext = existingContext.map(VerificationContext::createForResubmission).orElseGet(() -> VerificationContext.create(sourceQuery.getName(), sourceQuery.getSuite()));
    QueryActions queryActions = queryActionsFactory.create(sourceQuery, verificationContext);
    if (verifierConfig.isExplain()) {
        return new ExplainVerification(queryActions, sourceQuery, exceptionClassifier, verificationContext, verifierConfig, sqlParser);
    }
    QueryRewriter queryRewriter = queryRewriterFactory.create(queryActions.getHelperAction());
    switch(queryType) {
        case CREATE_TABLE_AS_SELECT:
        case INSERT:
        case QUERY:
            DeterminismAnalyzer determinismAnalyzer = new DeterminismAnalyzer(sourceQuery, queryActions.getHelperAction(), queryRewriter, checksumValidator, typeManager, determinismAnalyzerConfig);
            FailureResolverManager failureResolverManager = failureResolverManagerFactory.create(new FailureResolverFactoryContext(sqlParser, queryActions.getHelperAction()));
            return new DataVerification(queryActions, sourceQuery, queryRewriter, determinismAnalyzer, failureResolverManager, exceptionClassifier, verificationContext, verifierConfig, typeManager, checksumValidator);
        case CREATE_VIEW:
            return new CreateViewVerification(sqlParser, queryActions, sourceQuery, queryRewriter, exceptionClassifier, verificationContext, verifierConfig);
        case CREATE_TABLE:
            return new CreateTableVerification(sqlParser, queryActions, sourceQuery, queryRewriter, exceptionClassifier, verificationContext, verifierConfig);
        default:
            throw new IllegalStateException(format("Unsupported query type: %s", queryType));
    }
}
Also used : QueryActions(com.facebook.presto.verifier.prestoaction.QueryActions) FailureResolverManager(com.facebook.presto.verifier.resolver.FailureResolverManager) QueryRewriter(com.facebook.presto.verifier.rewrite.QueryRewriter) FailureResolverFactoryContext(com.facebook.presto.verifier.resolver.FailureResolverFactoryContext)

Aggregations

QueryActions (com.facebook.presto.verifier.prestoaction.QueryActions)1 FailureResolverFactoryContext (com.facebook.presto.verifier.resolver.FailureResolverFactoryContext)1 FailureResolverManager (com.facebook.presto.verifier.resolver.FailureResolverManager)1 QueryRewriter (com.facebook.presto.verifier.rewrite.QueryRewriter)1