use of io.crate.metadata.table.SchemaInfo in project crate by crate.
the class Schemas method tableExists.
public boolean tableExists(TableIdent tableIdent) {
SchemaInfo schemaInfo = schemas.get(firstNonNull(tableIdent.schema(), DEFAULT_SCHEMA_NAME));
if (schemaInfo == null) {
return false;
}
schemaInfo.invalidateTableCache(tableIdent.name());
TableInfo tableInfo = schemaInfo.getTableInfo(tableIdent.name());
if (tableInfo == null) {
return false;
} else if ((tableInfo instanceof DocTableInfo)) {
return !isOrphanedAlias((DocTableInfo) tableInfo);
}
return true;
}
use of io.crate.metadata.table.SchemaInfo in project crate by crate.
the class SchemasTest method testTableAliasIsNotWritable.
@Test
public void testTableAliasIsNotWritable() throws Exception {
expectedException.expect(UnsupportedOperationException.class);
expectedException.expectMessage("foo.bar is an alias. Write, Drop or Alter operations are not supported");
TableIdent tableIdent = new TableIdent("foo", "bar");
SchemaInfo schemaInfo = mock(SchemaInfo.class);
DocTableInfo tableInfo = mock(DocTableInfo.class);
when(tableInfo.ident()).thenReturn(tableIdent);
when(schemaInfo.getTableInfo(tableIdent.name())).thenReturn(tableInfo);
when(schemaInfo.name()).thenReturn(tableIdent.schema());
when(tableInfo.isAlias()).thenReturn(true);
Schemas schemas = getReferenceInfos(schemaInfo);
schemas.getWritableTable(tableIdent);
}
use of io.crate.metadata.table.SchemaInfo in project crate by crate.
the class SchemasTest method testSystemSchemaIsNotWritable.
@Test
public void testSystemSchemaIsNotWritable() throws Exception {
expectedException.expect(UnsupportedOperationException.class);
expectedException.expectMessage("The table foo.bar is read-only. Write, Drop or Alter operations are not supported");
TableIdent tableIdent = new TableIdent("foo", "bar");
SchemaInfo schemaInfo = mock(SchemaInfo.class);
TableInfo tableInfo = mock(TableInfo.class);
when(tableInfo.ident()).thenReturn(tableIdent);
when(schemaInfo.getTableInfo(tableIdent.name())).thenReturn(tableInfo);
when(schemaInfo.name()).thenReturn(tableIdent.schema());
Schemas schemas = getReferenceInfos(schemaInfo);
schemas.getWritableTable(tableIdent);
}
Aggregations