use of com.facebook.presto.verifier.prestoaction.QueryActions in project presto by prestodb.
the class AbstractVerificationTest method verify.
private Optional<VerifierQueryEvent> verify(SourceQuery sourceQuery, boolean explain, Optional<PrestoAction> mockPrestoAction) {
VerifierConfig verifierConfig = new VerifierConfig().setTestId(TEST_ID).setExplain(explain);
TypeManager typeManager = createTypeManager();
PrestoAction prestoAction = mockPrestoAction.orElseGet(() -> getPrestoAction(Optional.of(sourceQuery.getControlConfiguration())));
QueryRewriterFactory queryRewriterFactory = new VerificationQueryRewriterFactory(sqlParser, typeManager, new QueryRewriteConfig().setTablePrefix(CONTROL_TABLE_PREFIX), new QueryRewriteConfig().setTablePrefix(TEST_TABLE_PREFIX));
VerificationFactory verificationFactory = new VerificationFactory(sqlParser, (source, context) -> new QueryActions(prestoAction, prestoAction, prestoAction), queryRewriterFactory, failureResolverManagerFactory, createChecksumValidator(verifierConfig), exceptionClassifier, verifierConfig, typeManager, determinismAnalyzerConfig);
return verificationFactory.get(sourceQuery, Optional.empty()).run().getEvent();
}
use of com.facebook.presto.verifier.prestoaction.QueryActions 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