Class JdbcCatalogProvider
- All Implemented Interfaces:
CatalogProvider
CatalogProvider that introspects table schemas from a live database
over JDBC, used when a connection.table reference declares no schema.
Columns are read from DatabaseMetaData.getColumns(java.lang.String, java.lang.String, java.lang.String, java.lang.String), mapping SQL types
to relix ScalarTypes. Because identifier case-folding varies by dialect
(H2 folds to upper-case, PostgreSQL to lower-case), the table name is tried
as-given and then upper- and lower-cased. Any failure (unreachable database,
unknown table) yields Optional.empty() rather than throwing, so analysis
degrades to a clear "schema unavailable" diagnostic.
Statistics (tableStatistics(com.darkcollective.relix.lang.ast.ConnectionDeclaration, java.lang.String)) supply a COUNT(*) row count, the
primary-key columns, and per-column distinct/null counts (gathered in one
aggregate query), all read on demand. Each lookup opens a fresh connection and
performs no caching; connection reuse arrives in a later phase.
Connections come from a ConnectionProvider, so a connection whose
coordinates are not a URL can still be introspected. One analyzer holds one
catalog provider for every connection a script declares, including non-JDBC
ones; a declaration this provider cannot open is reported as
Optional.empty() — schema unavailable — rather than raised, which is
the same degradation an unreachable database already gets.
-
Field Summary
Fields inherited from interface com.darkcollective.relix.semantic.CatalogProvider
NONE -
Constructor Summary
ConstructorsConstructorDescriptionCreates a provider opening connections fromConnectionProvider.FROM_URL.JdbcCatalogProvider(ConnectionProvider connections) Creates a provider opening connections fromconnections. -
Method Summary
Modifier and TypeMethodDescriptiontableSchema(ConnectionDeclaration connection, String table) Returns the output schema oftablewithinconnection, orOptional.empty()if it cannot be determined.tableStatistics(ConnectionDeclaration connection, String table) Returns optimizer statistics (row count, keys) fortablewithinconnection, orOptional.empty()if none are available.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.darkcollective.relix.semantic.CatalogProvider
tables
-
Constructor Details
-
JdbcCatalogProvider
public JdbcCatalogProvider()Creates a provider opening connections fromConnectionProvider.FROM_URL. -
JdbcCatalogProvider
Creates a provider opening connections fromconnections.- Parameters:
connections- the source of introspection connections; must not be null
-
-
Method Details
-
tableSchema
Description copied from interface:CatalogProviderReturns the output schema oftablewithinconnection, orOptional.empty()if it cannot be determined.- Specified by:
tableSchemain interfaceCatalogProvider- 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
Description copied from interface:CatalogProviderReturns 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.
- Specified by:
tableStatisticsin interfaceCatalogProvider- 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
-