Class Schemas


  • public final class Schemas
    extends java.lang.Object
    Utility functions for schemas.
    • Constructor Detail

      • Schemas

        private Schemas()
    • Method Detail

      • expression

        public static Expression expression​(SchemaPlus schema)
        Returns the expression for a schema.
      • subSchemaExpression

        public static Expression subSchemaExpression​(SchemaPlus schema,
                                                     java.lang.String name,
                                                     java.lang.Class type)
        Returns the expression for a sub-schema.
      • tableExpression

        public static Expression tableExpression​(SchemaPlus schema,
                                                 java.lang.reflect.Type elementType,
                                                 java.lang.String tableName,
                                                 java.lang.Class clazz)
        Returns the expression to access a table within a schema.
      • createDataContext

        public static DataContext createDataContext​(java.sql.Connection connection,
                                                    SchemaPlus rootSchema)
      • queryable

        public static <E> Queryable<E> queryable​(DataContext root,
                                                 java.lang.Class<E> clazz,
                                                 java.lang.String... names)
        Returns a Queryable, given a fully-qualified table name.
      • queryable

        public static <E> Queryable<E> queryable​(DataContext root,
                                                 java.lang.Class<E> clazz,
                                                 java.lang.Iterable<? extends java.lang.String> names)
        Returns a Queryable, given a fully-qualified table name as an iterable.
      • queryable

        public static <E> Queryable<E> queryable​(DataContext root,
                                                 SchemaPlus schema,
                                                 java.lang.Class<E> clazz,
                                                 java.lang.String tableName)
        Returns a Queryable, given a schema and table name.
      • enumerable

        public static Enumerable<java.lang.Object[]> enumerable​(FilterableTable table,
                                                                DataContext root)
        Returns an Enumerable over the rows of a given table, not applying any filters, representing each row as an object array.
      • identity

        private static int[] identity​(int count)
      • makeContext

        private static CalcitePrepare.Context makeContext​(CalciteConnection connection,
                                                          CalciteSchema schema,
                                                          java.util.List<java.lang.String> schemaPath,
                                                          java.util.List<java.lang.String> objectPath,
                                                          com.google.common.collect.ImmutableMap<CalciteConnectionProperty,​java.lang.String> propValues)
        Creates a context for the purposes of preparing a statement.
        Parameters:
        connection - Connection
        schema - Schema
        schemaPath - Path wherein to look for functions
        objectPath - Path of the object being analyzed (usually a view), or null
        propValues - Connection properties
        Returns:
        Context
      • getStarTables

        public static java.util.List<CalciteSchema.TableEntry> getStarTables​(CalciteSchema schema)
        Returns the star tables defined in a schema.
        Parameters:
        schema - Schema
      • getLattices

        public static java.util.List<Lattice> getLattices​(CalciteSchema schema)
        Returns the lattices defined in a schema.
        Parameters:
        schema - Schema
      • subSchema

        public static CalciteSchema subSchema​(CalciteSchema schema,
                                              java.lang.Iterable<java.lang.String> names)
        Returns a sub-schema of a given schema obtained by following a sequence of names.

        The result is null if the initial schema is null or any sub-schema does not exist.

      • uniqueTableName

        public static java.lang.String uniqueTableName​(CalciteSchema schema,
                                                       java.lang.String base)
        Generates a table name that is unique within the given schema.
      • path

        public static Path path​(CalciteSchema rootSchema,
                                java.lang.Iterable<java.lang.String> names)
        Creates a path with a given list of names starting from a given root schema.
      • path

        public static Path path​(SchemaPlus schema)
        Returns the path to get to a schema from its root.