use of org.apache.ignite.internal.sql.engine.schema.SqlSchemaManager in project ignite-3 by apache.
the class RelJsonReaderTest method fromJson.
/**
* Test verifies that during deserialization table being resolved by its ID.
*/
@Test
void fromJson() {
UUID tableId = UUID.randomUUID();
int tableVer = 2;
IgniteTable igniteTableMock = mock(IgniteTable.class);
when(igniteTableMock.getStatistic()).thenReturn(new Statistic() {
});
when(igniteTableMock.getRowType(any())).thenReturn(mock(RelDataType.class));
SqlSchemaManager schemaMock = mock(SqlSchemaManager.class);
when(schemaMock.tableById(tableId, tableVer)).thenReturn(igniteTableMock);
String json = "" + "{\n" + " \"rels\" : [ {\n" + " \"id\" : \"0\",\n" + " \"relOp\" : \"IgniteTableScan\",\n" + " \"table\" : [\"PUBLIC\", \"TEST\"],\n" + " \"tableId\" : \"" + tableId + "\",\n" + " \"tableVer\" : " + tableVer + ",\n" + " \"inputs\" : [ ]\n" + " } ]\n" + "}";
RelNode node = RelJsonReader.fromJson(schemaMock, json);
assertThat(node, isA(IgniteTableScan.class));
assertThat(node.getTable(), notNullValue());
assertThat(node.getTable().unwrap(IgniteTable.class), is(igniteTableMock));
Mockito.verify(schemaMock).tableById(tableId, tableVer);
}
Aggregations