use of com.facebook.presto.Session in project presto by prestodb.
the class TestDistributedQueriesIndexed method createQueryRunner.
private static DistributedQueryRunner createQueryRunner() throws Exception {
Session session = testSessionBuilder().setCatalog("tpch_indexed").setSchema(TINY_SCHEMA_NAME).build();
DistributedQueryRunner queryRunner = new DistributedQueryRunner(session, 3);
queryRunner.installPlugin(new IndexedTpchPlugin(INDEX_SPEC));
queryRunner.createCatalog("tpch_indexed", "tpch_indexed");
return queryRunner;
}
use of com.facebook.presto.Session in project presto by prestodb.
the class TestLocalBinarySpilledQueries method createLocalQueryRunner.
private static LocalQueryRunner createLocalQueryRunner() {
Session defaultSession = testSessionBuilder().setCatalog("local").setSchema(TINY_SCHEMA_NAME).setSystemProperty(SystemSessionProperties.SPILL_ENABLED, "true").setSystemProperty(SystemSessionProperties.OPERATOR_MEMORY_LIMIT_BEFORE_SPILL, //spill constantly
"1B").build();
LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession);
// add the tpch catalog
// local queries run directly against the generator
localQueryRunner.createCatalog(defaultSession.getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
localQueryRunner.getMetadata().addFunctions(CUSTOM_FUNCTIONS);
SessionPropertyManager sessionPropertyManager = localQueryRunner.getMetadata().getSessionPropertyManager();
sessionPropertyManager.addSystemSessionProperties(TEST_SYSTEM_PROPERTIES);
sessionPropertyManager.addConnectorSessionProperties(new ConnectorId(TESTING_CATALOG), TEST_CATALOG_PROPERTIES);
return localQueryRunner;
}
use of com.facebook.presto.Session in project presto by prestodb.
the class TestLocalQueries method createLocalQueryRunner.
public static LocalQueryRunner createLocalQueryRunner() {
Session defaultSession = testSessionBuilder().setCatalog("local").setSchema(TINY_SCHEMA_NAME).setSystemProperty(REORDER_JOINS, "true").build();
LocalQueryRunner localQueryRunner = new LocalQueryRunner(defaultSession);
// add the tpch catalog
// local queries run directly against the generator
localQueryRunner.createCatalog(defaultSession.getCatalog().get(), new TpchConnectorFactory(1), ImmutableMap.of());
localQueryRunner.getMetadata().addFunctions(CUSTOM_FUNCTIONS);
SessionPropertyManager sessionPropertyManager = localQueryRunner.getMetadata().getSessionPropertyManager();
sessionPropertyManager.addSystemSessionProperties(TEST_SYSTEM_PROPERTIES);
sessionPropertyManager.addConnectorSessionProperties(new ConnectorId(TESTING_CATALOG), TEST_CATALOG_PROPERTIES);
return localQueryRunner;
}
use of com.facebook.presto.Session in project presto by prestodb.
the class RenameColumnTask method execute.
@Override
public ListenableFuture<?> execute(RenameColumn statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine, List<Expression> parameters) {
Session session = stateMachine.getSession();
QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getTable());
Optional<TableHandle> tableHandle = metadata.getTableHandle(session, tableName);
String source = statement.getSource().toLowerCase(ENGLISH);
String target = statement.getTarget().toLowerCase(ENGLISH);
if (!tableHandle.isPresent()) {
throw new SemanticException(MISSING_TABLE, statement, "Table '%s' does not exist", tableName);
}
accessControl.checkCanRenameColumn(session.getRequiredTransactionId(), session.getIdentity(), tableName);
Map<String, ColumnHandle> columnHandles = metadata.getColumnHandles(session, tableHandle.get());
if (!columnHandles.containsKey(source)) {
throw new SemanticException(MISSING_COLUMN, statement, "Column '%s' does not exist", source);
}
if (columnHandles.containsKey(target)) {
throw new SemanticException(COLUMN_ALREADY_EXISTS, statement, "Column '%s' already exists", target);
}
metadata.renameColumn(session, tableHandle.get(), columnHandles.get(source), target);
return immediateFuture(null);
}
use of com.facebook.presto.Session in project presto by prestodb.
the class ColumnJdbcTable method cursor.
@Override
public RecordCursor cursor(ConnectorTransactionHandle transactionHandle, ConnectorSession connectorSession, TupleDomain<Integer> constraint) {
Session session = toSession(transactionHandle, connectorSession);
Optional<String> catalogFilter = stringFilter(constraint, 0);
Optional<String> schemaFilter = stringFilter(constraint, 1);
Optional<String> tableFilter = stringFilter(constraint, 2);
Builder table = InMemoryRecordSet.builder(METADATA);
for (String catalog : filter(listCatalogs(session, metadata, accessControl).keySet(), catalogFilter)) {
QualifiedTablePrefix prefix = FilterUtil.tablePrefix(catalog, schemaFilter, tableFilter);
for (Entry<SchemaTableName, List<ColumnMetadata>> entry : listTableColumns(session, metadata, accessControl, prefix).entrySet()) {
addColumnRows(table, catalog, entry.getKey(), entry.getValue());
}
}
return table.build().cursor();
}
Aggregations