use of io.crate.testing.SQLExecutor in project crate by crate.
the class ValueNormalizerTest method prepare.
@Before
public void prepare() throws Exception {
SQLExecutor e = SQLExecutor.builder(clusterService).addTable("create table doc.test1 (" + " id long primary key," + " name string," + " d double," + " dyn_empty object," + " dyn object as (" + " d double," + " inner_strict object(strict) as (" + " double double" + " )" + " )," + " strict object(strict) as (" + " inner_d double" + " )," + " ignored object(ignored)" + ") " + "clustered by (id)").build();
userTableInfo = e.resolveTableInfo("doc.test1");
normalizer = EvaluatingNormalizer.functionOnlyNormalizer(e.nodeCtx);
}
use of io.crate.testing.SQLExecutor in project crate by crate.
the class SchemasTest method testResolveRelationThrowsRelationUnknownIfRelationIsNotInSearchPath.
@Test
public void testResolveRelationThrowsRelationUnknownIfRelationIsNotInSearchPath() throws IOException {
SQLExecutor sqlExecutor = getSqlExecutorBuilderForTable(new RelationName("schema", "t"), "doc", "schema").build();
QualifiedName table = QualifiedName.of("missing_table");
expectedException.expect(RelationUnknown.class);
expectedException.expectMessage("Relation 'missing_table' unknown");
sqlExecutor.schemas().resolveRelation(table, sqlExecutor.getSessionContext().searchPath());
}
use of io.crate.testing.SQLExecutor in project crate by crate.
the class SchemasTest method testResolveTableInfoForInvalidFQNThrowsSchemaUnknownException.
@Test
public void testResolveTableInfoForInvalidFQNThrowsSchemaUnknownException() throws IOException {
SQLExecutor sqlExecutor = getSqlExecutorBuilderForTable(new RelationName("schema", "t")).build();
QualifiedName invalidFqn = QualifiedName.of("bogus_schema", "t");
SessionContext sessionContext = sqlExecutor.getSessionContext();
expectedException.expect(SchemaUnknownException.class);
expectedException.expectMessage("Schema 'bogus_schema' unknown");
sqlExecutor.schemas().resolveTableInfo(invalidFqn, Operation.READ, sessionContext.sessionUser(), sessionContext.searchPath());
}
use of io.crate.testing.SQLExecutor in project crate by crate.
the class SchemasTest method testResolveTableInfoThrowsRelationUnknownIfRelationIsNotInSearchPath.
@Test
public void testResolveTableInfoThrowsRelationUnknownIfRelationIsNotInSearchPath() throws IOException {
SQLExecutor sqlExecutor = getSqlExecutorBuilderForTable(new RelationName("schema", "t")).build();
QualifiedName table = QualifiedName.of("missing_table");
SessionContext sessionContext = sqlExecutor.getSessionContext();
expectedException.expect(RelationUnknown.class);
expectedException.expectMessage("Relation 'missing_table' unknown");
sqlExecutor.schemas().resolveTableInfo(table, Operation.READ, sessionContext.sessionUser(), sessionContext.searchPath());
}
use of io.crate.testing.SQLExecutor in project crate by crate.
the class SchemasTest method testResolveRelationForTableAndView.
@Test
public void testResolveRelationForTableAndView() throws IOException {
SQLExecutor sqlExecutor = getSqlExecutorBuilderForTable(new RelationName("schema", "t"), "doc", "schema").addView(new RelationName("schema", "view"), "select 1").build();
QualifiedName table = QualifiedName.of("t");
RelationName tableRelation = sqlExecutor.schemas().resolveRelation(table, sqlExecutor.getSessionContext().searchPath());
assertThat(tableRelation.schema(), is("schema"));
assertThat(tableRelation.name(), is("t"));
QualifiedName view = QualifiedName.of("view");
RelationName viewRelation = sqlExecutor.schemas().resolveRelation(view, sqlExecutor.getSessionContext().searchPath());
assertThat(viewRelation.schema(), is("schema"));
assertThat(viewRelation.name(), is("view"));
}
Aggregations