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));
}
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));
}
}
Aggregations