Interface CatalogProvider
- All Known Implementing Classes:
CatalogSnapshot,ConnectorCatalogProvider,JdbcCatalogProvider
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
This is the seam through which the analyzer learns the schema of a table
referenced by a connection (e.g. sales.orders) when no schema was
declared in the script. A real implementation introspects the live database;
the default NONE resolves nothing, so dotted references without a
declared schema produce a clear "schema unavailable" error in offline use.
The seam also supplies optional RelationStatistics (row counts,
keys) for the cost model via tableStatistics(com.darkcollective.relix.lang.ast.ConnectionDeclaration, java.lang.String), and the tables a connection
holds via tables(com.darkcollective.relix.lang.ast.ConnectionDeclaration); both default to Optional.empty(), so a schema-only
provider needs no extra work.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CatalogProviderA provider that resolves nothing — the default for offline analysis. -
Method Summary
Modifier and TypeMethodDescriptiontables(ConnectionDeclaration connection) Returns the names of the tablesconnectionholds, as far as this provider knows them, orOptional.empty()if it cannot enumerate them.tableSchema(ConnectionDeclaration connection, String table) Returns the output schema oftablewithinconnection, orOptional.empty()if it cannot be determined.default Optional<RelationStatistics> tableStatistics(ConnectionDeclaration connection, String table) Returns optimizer statistics (row count, keys) fortablewithinconnection, orOptional.empty()if none are available.
-
Field Details
-
NONE
A provider that resolves nothing — the default for offline analysis.
-
-
Method Details
-
tableSchema
Returns the output schema oftablewithinconnection, orOptional.empty()if it cannot be determined.- Parameters:
connection- the declared connection the table belongs totable- the (possibly schema-qualified) remote table name- Returns:
- the table's schema, or empty if unavailable
-
tableStatistics
default Optional<RelationStatistics> tableStatistics(ConnectionDeclaration connection, String table) Returns optimizer statistics (row count, keys) fortablewithinconnection, orOptional.empty()if none are available.The default returns empty; introspecting providers override this to query the live catalog. Statistics are advisory: a missing or partial value never affects correctness, only the quality of cost-based decisions.
- Parameters:
connection- the declared connection the table belongs totable- the (possibly schema-qualified) remote table name- Returns:
- the table's statistics, or empty if unavailable
-
tables
Returns the names of the tablesconnectionholds, as far as this provider knows them, orOptional.empty()if it cannot enumerate them.The analyser uses the list to suggest a table when a reference names one the provider cannot describe, as it already suggests a column. The default returns empty, which suits live introspection: asking a database for every table to correct one typo is not a cost worth paying during analysis. A provider holding a fixed set of tables, such as a
CatalogSnapshot, lists them.- Parameters:
connection- the declared connection- Returns:
- the table names, as a reference would spell them after the connection's name; or empty if this provider cannot enumerate them
-