Java Code Examples for org.apache.calcite.DataContext#getRootSchema()

The following examples show how to use org.apache.calcite.DataContext#getRootSchema() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Schemas.java    From Bats with Apache License 2.0 5 votes vote down vote up
/** Returns an {@link org.apache.calcite.util.Enumerable} over object
 * arrays, given a fully-qualified table name which leads to a
 * {@link ScannableTable}. */
public static Table table(DataContext root, String... names) {
  SchemaPlus schema = root.getRootSchema();
  final List<String> nameList = Arrays.asList(names);
  for (Iterator<? extends String> iterator = nameList.iterator();;) {
    String name = iterator.next();
    if (iterator.hasNext()) {
      schema = schema.getSubSchema(name);
    } else {
      return schema.getTable(name);
    }
  }
}
 
Example 2
Source File: Schemas.java    From calcite with Apache License 2.0 5 votes vote down vote up
/** Returns a {@link Queryable}, given a fully-qualified table name as an
 * iterable. */
public static <E> Queryable<E> queryable(DataContext root, Class<E> clazz,
    Iterable<? extends String> names) {
  SchemaPlus schema = root.getRootSchema();
  for (Iterator<? extends String> iterator = names.iterator();;) {
    String name = iterator.next();
    if (iterator.hasNext()) {
      schema = schema.getSubSchema(name);
    } else {
      return queryable(root, schema, clazz, name);
    }
  }
}
 
Example 3
Source File: Schemas.java    From calcite with Apache License 2.0 5 votes vote down vote up
/** Returns an {@link org.apache.calcite.linq4j.Enumerable} over object
 * arrays, given a fully-qualified table name which leads to a
 * {@link ScannableTable}. */
public static Table table(DataContext root, String... names) {
  SchemaPlus schema = root.getRootSchema();
  final List<String> nameList = Arrays.asList(names);
  for (Iterator<? extends String> iterator = nameList.iterator();;) {
    String name = iterator.next();
    if (iterator.hasNext()) {
      schema = schema.getSubSchema(name);
    } else {
      return schema.getTable(name);
    }
  }
}