Search in sources :

Example 1 with SqlSchemaManager

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);
}
Also used : SqlSchemaManager(org.apache.ignite.internal.sql.engine.schema.SqlSchemaManager) IgniteTable(org.apache.ignite.internal.sql.engine.schema.IgniteTable) Statistic(org.apache.calcite.schema.Statistic) RelNode(org.apache.calcite.rel.RelNode) RelDataType(org.apache.calcite.rel.type.RelDataType) UUID(java.util.UUID) IgniteTableScan(org.apache.ignite.internal.sql.engine.rel.IgniteTableScan) Test(org.junit.jupiter.api.Test)

Aggregations

UUID (java.util.UUID)1 RelNode (org.apache.calcite.rel.RelNode)1 RelDataType (org.apache.calcite.rel.type.RelDataType)1 Statistic (org.apache.calcite.schema.Statistic)1 IgniteTableScan (org.apache.ignite.internal.sql.engine.rel.IgniteTableScan)1 IgniteTable (org.apache.ignite.internal.sql.engine.schema.IgniteTable)1 SqlSchemaManager (org.apache.ignite.internal.sql.engine.schema.SqlSchemaManager)1 Test (org.junit.jupiter.api.Test)1