public static Table resolveCalciteTable(SchemaPlus schemaPlus, List<String> tablePath) {
    Schema subSchema = schemaPlus;

    // subSchema.getSubschema() for all except last
    for (int i = 0; i < tablePath.size() - 1; i++) {
      subSchema = subSchema.getSubSchema(tablePath.get(i));
      if (subSchema == null) {
        throw new IllegalStateException(
            String.format(
                "While resolving table path %s, no sub-schema found for component %s (\"%s\")",
                tablePath, i, tablePath.get(i)));
      }
    }

    // for the final one call getTable()
    return subSchema.getTable(Iterables.getLast(tablePath));
  }
@Test
  public void testResolveNestedWithDots() {
    String subSchema = "fake.schema";
    String tableName = "fake.table";
    when(mockSchemaPlus.getSubSchema(subSchema)).thenReturn(innerSchemaPlus);
    when(innerSchemaPlus.getTable(tableName)).thenReturn(mockTable);
    Table table =
        TableResolution.resolveCalciteTable(mockSchemaPlus, ImmutableList.of(subSchema, tableName));
    assertThat(table, Matchers.is(mockTable));
  }