Affects Version/s: None
Fix Version/s: None
Currently you can only create a Schema when you have a QueryProvider, and the usual implementation of QueryProvider is an OptiqConnection. Thus you have to build a Schema for each connection. The reason for this is that each Table implements Queryable, and therefore needs to contain sufficient information that you can call enumerator() on any Table.
Also, if a Schema is to be long-lived, it cannot own a type-factory. One of the important functions of RelDataTypeFactory is to convert types to canonical form: for two instances of RelDataType t1 and t2 created by the same type factory, t1.equals(t2) if and only if t1 == t2. But if type factory is long-lived, the list of canonized types can build up and behave like a memory leak.
- remove Schema.getTypeFactory() and Schema.getQueryProvider() methods;
- Table would no longer implement Queryable;
- add a new method Table.toQueryable(QueryProvider);
- add a interface Type, with method RelDataType Type.toOptiqType(RelDataTypeFactory)
- change Table.getRowType() to return Type, not RelDataType.
The changes to the type system allow tables to represent their type in whichever way is best for their domain. The toOptiqType method is called within the context of a statement, and can therefore use a type factory to canonize the RelDataType objects it returns. But optiq does not require or expect that Type instances are canonical.