use of io.trino.sql.tree.AllColumns in project trino by trinodb.
the class TestPrepareTask method testPrepare.
@Test
public void testPrepare() {
Query query = simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("foo")));
String sqlString = "PREPARE my_query FROM SELECT * FROM foo";
Map<String, String> statements = executePrepare("my_query", query, sqlString, TEST_SESSION);
assertEquals(statements, ImmutableMap.of("my_query", "SELECT *\nFROM\n foo\n"));
}
use of io.trino.sql.tree.AllColumns in project trino by trinodb.
the class TestQueryPreparer method testSelectStatement.
@Test
public void testSelectStatement() {
PreparedQuery preparedQuery = QUERY_PREPARER.prepareQuery(TEST_SESSION, "SELECT * FROM foo");
assertEquals(preparedQuery.getStatement(), simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("foo"))));
}
use of io.trino.sql.tree.AllColumns in project trino by trinodb.
the class TestQueryPreparer method testExecuteStatement.
@Test
public void testExecuteStatement() {
Session session = testSessionBuilder().addPreparedStatement("my_query", "SELECT * FROM foo").build();
PreparedQuery preparedQuery = QUERY_PREPARER.prepareQuery(session, "EXECUTE my_query");
assertEquals(preparedQuery.getStatement(), simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("foo"))));
}
use of io.trino.sql.tree.AllColumns in project trino by trinodb.
the class TestPrepareTask method testPrepareNameExists.
@Test
public void testPrepareNameExists() {
Session session = testSessionBuilder().addPreparedStatement("my_query", "SELECT bar, baz from foo").build();
Query query = simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("foo")));
String sqlString = "PREPARE my_query FROM SELECT * FROM foo";
Map<String, String> statements = executePrepare("my_query", query, sqlString, session);
assertEquals(statements, ImmutableMap.of("my_query", "SELECT *\nFROM\n foo\n"));
}
use of io.trino.sql.tree.AllColumns in project trino by trinodb.
the class TestCreateMaterializedViewTask method testCreateDenyPermission.
@Test
public void testCreateDenyPermission() {
CreateMaterializedView statement = new CreateMaterializedView(Optional.empty(), QualifiedName.of("test_mv"), simpleQuery(selectList(new AllColumns()), table(QualifiedName.of("catalog", "schema", "mock_table"))), false, true, ImmutableList.of(), Optional.empty());
TestingAccessControlManager accessControl = new TestingAccessControlManager(transactionManager, emptyEventListenerManager());
accessControl.loadSystemAccessControl(AllowAllSystemAccessControl.NAME, ImmutableMap.of());
accessControl.deny(privilege("test_mv", CREATE_MATERIALIZED_VIEW));
StatementAnalyzerFactory statementAnalyzerFactory = createTestingStatementAnalyzerFactory(plannerContext, accessControl, new TablePropertyManager(), new AnalyzePropertyManager());
AnalyzerFactory analyzerFactory = new AnalyzerFactory(statementAnalyzerFactory, new StatementRewrite(ImmutableSet.of()));
assertThatThrownBy(() -> getFutureValue(new CreateMaterializedViewTask(plannerContext, accessControl, parser, analyzerFactory, materializedViewPropertyManager, new FeaturesConfig()).execute(statement, queryStateMachine, ImmutableList.of(), WarningCollector.NOOP))).isInstanceOf(AccessDeniedException.class).hasMessageContaining("Cannot create materialized view catalog.schema.test_mv");
}
Aggregations