use of com.facebook.presto.sql.parser.SqlParser in project presto by prestodb.
the class TestDropFunctionTask method executeAndGetRemovedSessionFunctions.
private Set<SqlFunctionId> executeAndGetRemovedSessionFunctions(String sqlString, Session session) {
SqlParser parser = new SqlParser();
DropFunction statement = (DropFunction) parser.createStatement(sqlString, ParsingOptions.builder().build());
TransactionManager tm = createTestTransactionManager();
QueryStateMachine stateMachine = createQueryStateMachine(sqlString, session, false, tm, executorService, metadataManager);
WarningCollector warningCollector = stateMachine.getWarningCollector();
DropFunctionTask dropFunctionTask = new DropFunctionTask(parser);
dropFunctionTask.execute(statement, tm, metadataManager, new AllowAllAccessControl(), session, emptyList(), warningCollector);
return dropFunctionTask.getRemovedSessionFunctions();
}
use of com.facebook.presto.sql.parser.SqlParser in project presto by prestodb.
the class TestSetRoleTask method setUp.
@BeforeClass
public void setUp() throws Exception {
CatalogManager catalogManager = new CatalogManager();
transactionManager = createTestTransactionManager(catalogManager);
accessControl = new AllowAllAccessControl();
metadata = MetadataManager.createTestMetadataManager(transactionManager, new FeaturesConfig());
catalogManager.registerCatalog(createBogusTestingCatalog(CATALOG_NAME));
executor = newCachedThreadPool(daemonThreadsNamed("test-set-role-task-executor-%s"));
parser = new SqlParser();
}
use of com.facebook.presto.sql.parser.SqlParser in project presto by prestodb.
the class TestPrepareTask method executePrepare.
private Map<String, String> executePrepare(String statementName, Statement statement, String sqlString, Session session) {
TransactionManager transactionManager = createTestTransactionManager();
QueryStateMachine stateMachine = createQueryStateMachine(sqlString, session, false, transactionManager, executor, metadata);
Prepare prepare = new Prepare(identifier(statementName), statement);
PrepareTask prepareTask = new PrepareTask(new SqlParser());
prepareTask.execute(prepare, transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList());
return stateMachine.getAddedPreparedStatements();
}
use of com.facebook.presto.sql.parser.SqlParser in project presto by prestodb.
the class TestCommonSubExpressionRewritter method rowExpression.
private RowExpression rowExpression(String sql) {
Expression expression = rewriteIdentifiersToSymbolReferences(new SqlParser().createExpression(sql));
Map<NodeRef<Expression>, Type> expressionTypes = getExpressionTypes(SESSION, METADATA, new SqlParser(), TYPES, expression, ImmutableList.of(), WarningCollector.NOOP);
return SqlToRowExpressionTranslator.translate(expression, expressionTypes, ImmutableMap.of(), METADATA.getFunctionAndTypeManager(), SESSION);
}
use of com.facebook.presto.sql.parser.SqlParser in project presto by prestodb.
the class TestVariableExtractor method assertVariables.
private static void assertVariables(String expression) {
Expression expected = rewriteIdentifiersToSymbolReferences(new SqlParser().createExpression(expression, new ParsingOptions()));
RowExpression actual = TRANSLATOR.translate(expected, SYMBOL_TYPES);
assertEquals(VariablesExtractor.extractUnique(expected, SYMBOL_TYPES), extractUnique(actual));
assertEquals(VariablesExtractor.extractAll(expected, SYMBOL_TYPES).stream().sorted().collect(toImmutableList()), extractAll(actual).stream().sorted().collect(toImmutableList()));
}
Aggregations