Search in sources :

Example 1 with QueryRewriter

use of com.facebook.presto.verifier.rewrite.QueryRewriter in project presto by prestodb.

the class TestDeterminismAnalyzer method createDeterminismAnalyzer.

private static DeterminismAnalyzer createDeterminismAnalyzer(String mutableCatalogPattern) {
    QueryConfiguration configuration = new QueryConfiguration(CATALOG, SCHEMA, Optional.of("user"), Optional.empty(), Optional.empty());
    VerificationContext verificationContext = VerificationContext.create(SUITE, NAME);
    VerifierConfig verifierConfig = new VerifierConfig().setTestId("test-id");
    RetryConfig retryConfig = new RetryConfig();
    QueryActionsConfig queryActionsConfig = new QueryActionsConfig();
    TypeManager typeManager = createTypeManager();
    PrestoAction prestoAction = new JdbcPrestoAction(PrestoExceptionClassifier.defaultBuilder().build(), configuration, verificationContext, new JdbcUrlSelector(ImmutableList.of()), new PrestoActionConfig(), queryActionsConfig.getMetadataTimeout(), queryActionsConfig.getChecksumTimeout(), retryConfig, retryConfig, verifierConfig);
    QueryRewriter queryRewriter = new QueryRewriter(sqlParser, typeManager, prestoAction, ImmutableMap.of(CONTROL, QualifiedName.of("tmp_verifier_c"), TEST, QualifiedName.of("tmp_verifier_t")), ImmutableMap.of());
    ChecksumValidator checksumValidator = createChecksumValidator(verifierConfig);
    SourceQuery sourceQuery = new SourceQuery("test", "", "", "", configuration, configuration);
    return new DeterminismAnalyzer(sourceQuery, prestoAction, queryRewriter, checksumValidator, typeManager, new DeterminismAnalyzerConfig().setNonDeterministicCatalogs(mutableCatalogPattern));
}
Also used : QueryActionsConfig(com.facebook.presto.verifier.prestoaction.QueryActionsConfig) JdbcPrestoAction(com.facebook.presto.verifier.prestoaction.JdbcPrestoAction) PrestoAction(com.facebook.presto.verifier.prestoaction.PrestoAction) PrestoActionConfig(com.facebook.presto.verifier.prestoaction.PrestoActionConfig) QueryRewriter(com.facebook.presto.verifier.rewrite.QueryRewriter) JdbcPrestoAction(com.facebook.presto.verifier.prestoaction.JdbcPrestoAction) RetryConfig(com.facebook.presto.verifier.retry.RetryConfig) TypeManager(com.facebook.presto.common.type.TypeManager) VerifierTestUtil.createTypeManager(com.facebook.presto.verifier.VerifierTestUtil.createTypeManager) VerifierTestUtil.createChecksumValidator(com.facebook.presto.verifier.VerifierTestUtil.createChecksumValidator) ChecksumValidator(com.facebook.presto.verifier.checksum.ChecksumValidator) JdbcUrlSelector(com.facebook.presto.verifier.prestoaction.JdbcUrlSelector)

Example 2 with QueryRewriter

use of com.facebook.presto.verifier.rewrite.QueryRewriter 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

QueryRewriter (com.facebook.presto.verifier.rewrite.QueryRewriter)2 TypeManager (com.facebook.presto.common.type.TypeManager)1 VerifierTestUtil.createChecksumValidator (com.facebook.presto.verifier.VerifierTestUtil.createChecksumValidator)1 VerifierTestUtil.createTypeManager (com.facebook.presto.verifier.VerifierTestUtil.createTypeManager)1 ChecksumValidator (com.facebook.presto.verifier.checksum.ChecksumValidator)1 JdbcPrestoAction (com.facebook.presto.verifier.prestoaction.JdbcPrestoAction)1 JdbcUrlSelector (com.facebook.presto.verifier.prestoaction.JdbcUrlSelector)1 PrestoAction (com.facebook.presto.verifier.prestoaction.PrestoAction)1 PrestoActionConfig (com.facebook.presto.verifier.prestoaction.PrestoActionConfig)1 QueryActions (com.facebook.presto.verifier.prestoaction.QueryActions)1 QueryActionsConfig (com.facebook.presto.verifier.prestoaction.QueryActionsConfig)1 FailureResolverFactoryContext (com.facebook.presto.verifier.resolver.FailureResolverFactoryContext)1 FailureResolverManager (com.facebook.presto.verifier.resolver.FailureResolverManager)1 RetryConfig (com.facebook.presto.verifier.retry.RetryConfig)1