Create a read-consistent view of CalciteSchema for each statement compilation

Details

Description

CalciteSchema is designed to have two sets of objects, the explicit and the implicit. A explicit object means an object we add through explicit CalciteSchema#addTable (or CalciteSchema.addFunction, etc) calls, while an implicit object means an object we get from the underlying Schema object's getXXX methods.

However, in CalciteCatalogReader#getTableFrom, after a table is resolved through CalciteSchema.getTable method, it will be added to the CalciteSchema again as an explicit object regardless of whether it is originally implicit or explicit. So if it happens to be an implicit table, any change about that table later on will be shadowed by the newly added explicit object and thus cannot be accessed.

Attachments

Issue Links

is depended upon by

PHOENIX-3341Schema update is not visible to following statements of the same connection due to CalciteSchema caching.

Resolved

is part of

CALCITE-911Add a variant of CalciteSchema that does not cache sub-objects