use of io.crate.testing.SQLExecutor in project crate by crate.
the class DocLevelExpressionsTest method prepare.
@Before
public void prepare() throws Exception {
SQLExecutor e = SQLExecutor.builder(clusterService).addTable(createTableStatement).build();
indexEnv = new IndexEnv(THREAD_POOL, (DocTableInfo) StreamSupport.stream(e.schemas().spliterator(), false).filter(x -> x instanceof DocSchemaInfo).map(x -> (DocSchemaInfo) x).findFirst().orElseThrow(() -> new IllegalStateException("No doc schema found")).getTables().iterator().next(), clusterService.state(), Version.CURRENT, createTempDir());
IndexWriter writer = indexEnv.writer();
insertValues(writer);
DirectoryReader directoryReader = DirectoryReader.open(writer, true, true);
readerContext = directoryReader.leaves().get(0);
ctx = new CollectorContext();
}
use of io.crate.testing.SQLExecutor in project crate by crate.
the class SysNodesTableInfoTest method test_column_that_is_a_child_of_an_array_has_array_type_on_select.
@Test
public void test_column_that_is_a_child_of_an_array_has_array_type_on_select() {
var table = SysNodesTableInfo.create();
Reference ref = table.getReference(new ColumnIdent("fs", List.of("data", "path")));
assertThat(ref.valueType(), is(new ArrayType<>(DataTypes.STRING)));
SQLExecutor e = SQLExecutor.builder(clusterService).build();
AnalyzedRelation statement = e.analyze("select fs['data']['path'] from sys.nodes");
assertThat(statement.outputs().get(0).valueType(), is(new ArrayType<>(DataTypes.STRING)));
}
use of io.crate.testing.SQLExecutor in project crate by crate.
the class SchemasTest method testResolveTableInfoForValidFQN.
@Test
public void testResolveTableInfoForValidFQN() throws IOException {
RelationName tableIdent = new RelationName("schema", "t");
SQLExecutor sqlExecutor = getSqlExecutorBuilderForTable(tableIdent, "doc", "schema").build();
QualifiedName fqn = QualifiedName.of("schema", "t");
SessionContext sessionContext = sqlExecutor.getSessionContext();
TableInfo tableInfo = sqlExecutor.schemas().resolveTableInfo(fqn, Operation.READ, sessionContext.sessionUser(), sessionContext.searchPath());
RelationName relation = tableInfo.ident();
assertThat(relation.schema(), is("schema"));
assertThat(relation.name(), is("t"));
}
use of io.crate.testing.SQLExecutor in project crate by crate.
the class DropViewAnalyzerTest method testDropViewRaisesRelationsUnkownForMissingView.
@Test
public void testDropViewRaisesRelationsUnkownForMissingView() {
SQLExecutor e = SQLExecutor.builder(clusterService).build();
expectedException.expect(RelationsUnknown.class);
expectedException.expectMessage("Relations not found: doc.v1, doc.v2");
e.analyze("drop view v1, v2");
}
use of io.crate.testing.SQLExecutor in project crate by crate.
the class DropViewAnalyzerTest method testDropViewContainsIfExistsAndEmptyViews.
@Test
public void testDropViewContainsIfExistsAndEmptyViews() {
SQLExecutor e = SQLExecutor.builder(clusterService).build();
AnalyzedDropView dropView = e.analyze("drop view if exists v1, v2, x.v3");
assertThat(dropView.ifExists(), is(true));
assertThat(dropView.views(), is(empty()));
}
Aggregations