use of io.trino.spi.StandardErrorCode.NOT_FOUND in project trino by trinodb.
the class TestErrorThrowableInQuery method createQueryRunner.
@Override
protected DistributedQueryRunner createQueryRunner() throws Exception {
Session session = testSessionBuilder().setSystemProperty("task_concurrency", "1").setCatalog("mock").setSchema("default").setClientInfo("{\"clientVersion\":\"testVersion\"}").build();
DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(session).setNodeCount(1).build();
try {
queryRunner.installPlugin(new TpchPlugin());
queryRunner.installPlugin(new ResourceGroupManagerPlugin());
queryRunner.installPlugin(new Plugin() {
@Override
public Iterable<ConnectorFactory> getConnectorFactories() {
SchemaTableName stackOverflowErrorTableName = new SchemaTableName("default", "stack_overflow_during_planning");
SchemaTableName classFormatErrorTableName = new SchemaTableName("default", "class_format_error_during_planning");
MockConnectorFactory connectorFactory = MockConnectorFactory.builder().withListTables((session, s) -> ImmutableList.of(stackOverflowErrorTableName)).withGetColumns(schemaTableName -> ImmutableList.of(new ColumnMetadata("test_varchar", createUnboundedVarcharType()), new ColumnMetadata("test_bigint", BIGINT))).withGetTableHandle((session, schemaTableName) -> new MockConnectorTableHandle(schemaTableName)).withApplyProjection((session, handle, projections, assignments) -> {
MockConnectorTableHandle mockTableHandle = (MockConnectorTableHandle) handle;
if (stackOverflowErrorTableName.equals(mockTableHandle.getTableName())) {
throw new StackOverflowError("We run out of stack!!!!!!!!!!!");
}
if (classFormatErrorTableName.equals(mockTableHandle.getTableName())) {
throw new ClassFormatError("Bad class format!!!!!!!!!!");
}
throw new TrinoException(NOT_FOUND, "Unknown table: " + mockTableHandle.getTableName());
}).build();
return ImmutableList.of(connectorFactory);
}
});
queryRunner.createCatalog("mock", "mock", ImmutableMap.of());
} catch (Exception e) {
queryRunner.close();
throw e;
}
return queryRunner;
}
use of io.trino.spi.StandardErrorCode.NOT_FOUND in project trino by trinodb.
the class UseTask method execute.
@Override
public ListenableFuture<Void> execute(Use statement, QueryStateMachine stateMachine, List<Expression> parameters, WarningCollector warningCollector) {
Session session = stateMachine.getSession();
String catalog = statement.getCatalog().map(identifier -> identifier.getValue().toLowerCase(ENGLISH)).orElseGet(() -> session.getCatalog().orElseThrow(() -> semanticException(MISSING_CATALOG_NAME, statement, "Catalog must be specified when session catalog is not set")));
if (metadata.getCatalogHandle(session, catalog).isEmpty()) {
throw new TrinoException(NOT_FOUND, "Catalog does not exist: " + catalog);
}
String schema = statement.getSchema().getValue().toLowerCase(ENGLISH);
CatalogSchemaName name = new CatalogSchemaName(catalog, schema);
if (!metadata.schemaExists(session, name)) {
throw new TrinoException(NOT_FOUND, "Schema does not exist: " + name);
}
if (statement.getCatalog().isPresent()) {
stateMachine.setSetCatalog(catalog);
}
stateMachine.setSetSchema(schema);
return immediateVoidFuture();
}
use of io.trino.spi.StandardErrorCode.NOT_FOUND in project trino by trinodb.
the class TableProceduresPropertyManager method getProperties.
public Map<String, Object> getProperties(CatalogName catalog, String procedureName, Map<String, Expression> sqlPropertyValues, Session session, PlannerContext plannerContext, AccessControl accessControl, Map<NodeRef<Parameter>, Expression> parameters) {
Map<String, PropertyMetadata<?>> supportedProperties = connectorProperties.get(new Key(catalog, procedureName));
if (supportedProperties == null) {
throw new TrinoException(NOT_FOUND, format("Catalog '%s' table procedure '%s' property not found", catalog, procedureName));
}
Map<String, Optional<Object>> propertyValues = evaluateProperties(sqlPropertyValues.entrySet().stream().map(entry -> new Property(new Identifier(entry.getKey()), entry.getValue())).collect(toImmutableList()), session, plannerContext, accessControl, parameters, true, supportedProperties, INVALID_PROCEDURE_ARGUMENT, format("catalog '%s' table procedure '%s' property", catalog, procedureName));
return propertyValues.entrySet().stream().filter(entry -> entry.getValue().isPresent()).collect(toImmutableMap(Entry::getKey, entry -> entry.getValue().orElseThrow()));
}
Aggregations