class TableResolution {

  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));
  }

}