public final class SqlflowCatalogInputReader extends Object implements CatalogInputReader
CatalogInputKind.SQLFLOW_JSON sources — the JSON shape the legacy
SqlflowSQLEnv consumes (plan §11 T2.A.3 / second Phase 2.A static-file adapter).
Per plan §6 / §11.2 this reader funnels the SqlFlow export shape into the same
UnifiedCatalogModel the JSON-manifest and SQLDep readers use; the eager bridge
then materializes a TSQLEnv byte-for-byte equivalent (for the SELECT smoke
surface) to what the legacy SqlflowSQLEnv would build (parity test in
SqlflowLegacyParityTest). The legacy path remains untouched per plan §8.5.
The root JSON is the SqlFlow "server" object. Three layouts depending on dialect:
{
"name": "<server label>",
"dbVendor": "dbvoracle", // optional vendor override (informational)
"databases": [
{
"name": "ORCL",
"schemas": [
{
"name": "HR",
"tables": [{"name": "EMPLOYEES", "type": "TABLE",
"columns": [{"name": "EMPLOYEE_ID"}, ...]}, ...],
"views": [{"name": "EMP_DETAILS_VIEW", "type": "VIEW",
"columns": [...]}, ...],
"packages": [{"name": "HR_PKG",
"procedures": [...], "functions": [...], "triggers": [...]}],
"procedures": [{"name": "ADD_EMP"}],
"functions": [{"name": "GET_SAL"}],
"triggers": [{"name": "AUDIT_TRG"}]
}
]
}
]
}
supportSchema=false)
{
"databases": [
{
"name": "mydb",
"tables": [...],
"views": [...],
"packages": [...],
"procedures": [...],
"functions": [...],
"triggers": [...]
}
]
}
The legacy SqlflowSQLEnv guards Layout C with supportCatalog(vendor),
which currently returns true for every dialect. This branch is therefore dead
in production, but a SqlFlow export pinned to that shape is still tolerated here for
defensive reasons — the model is built under the TSQLEnv.DEFAULT_DB_NAME
catalog the way the legacy code would.
tables[] and views[] are walked in insertion order
(tables first, views second), matching the legacy appendTables method.
For each entry the type field is examined: if it contains the substring
"view" (case-insensitive ASCII) the entry is recorded as a
ViewModel; otherwise as a TableModel. Array membership is
informational only — the type field wins.procedures[] → RoutineModel with CatalogObjectKind.PROCEDURE.functions[] → RoutineModel with CatalogObjectKind.FUNCTION.packages[] → RoutineModel with CatalogObjectKind.PACKAGE.
The package's nested procedures[] / functions[] / triggers[]
have no Phase 1 SPI representation and are dropped (the legacy loader binds them
inside the TSQLEnv's package node — that nesting belongs in a follow-up
extension to RoutineModel). The empty package shell is still present so
callers that resolve SCHEMA.PKG succeed.triggers[] (top-level or package-nested) — there is no Phase 1
RoutineModel.kind mapping for triggers and the SQLEnvCatalogLoader
does not synthesize them. They are dropped silently. SELECT-only smoke tests are
unaffected (triggers do not participate in TSQLResolver2 formatter
output for SELECT/JOIN queries); future Phase 2 work that needs
trigger metadata should extend the SPI.dbVendor JSON field is informational. The reader honors
CatalogLoadOptions.vendor() as the single source of truth (defaulting to
EDbVendor.dbvoracle when the option is unset, matching SqlFlow's historical
Oracle-leaning default). A mismatch between the JSON's dbVendor and the
option's vendor is not flagged here — CatalogModelValidator catches the
harmful identifier-bypass cases through its normalize round-trip.The reader is dispatch-by-CatalogInputKind.SQLFLOW_JSON only — callers must
tag the source explicitly. There is no auto-claim heuristic on JSON structure (the
SqlFlow shape and the SQLDep shape both top-level objects with a databases
array would collide); the explicit kind tag is the contract.
Identifier names with embedded dots are wrapped with the vendor's quote characters
before storage. Without the wrap, ModelBackedCatalogProvider later concatenates
segments with . into qualified strings (e.g. catalog.schema.A.B) that
CatalogIdentifierPolicy.parse would split into four segments instead of three,
and the runtime would never resolve the SQL reference "A.B". Mirrors the
SQLDepSQLEnv defense and the same wrapping policy as SqldepCatalogInputReader.
The vendor → delimiter-pair table is duplicated from TSQLEnv.delimitedChar to
keep catalog/** free of a compile-time dependency on the sqlenv runtime
layer.
| Modifier and Type | Class and Description |
|---|---|
static class |
SqlflowCatalogInputReader.Factory
ServiceLoader-discoverable factory.
|
| Constructor and Description |
|---|
SqlflowCatalogInputReader() |
| Modifier and Type | Method and Description |
|---|---|
CatalogInputKind |
kind() |
UnifiedCatalogModel |
read(CatalogInputSource source,
CatalogLoadOptions options) |
boolean |
supports(CatalogInputSource source,
CatalogLoadOptions options) |
public SqlflowCatalogInputReader()
public CatalogInputKind kind()
kind in interface CatalogInputReaderpublic boolean supports(CatalogInputSource source, CatalogLoadOptions options)
supports in interface CatalogInputReaderpublic UnifiedCatalogModel read(CatalogInputSource source, CatalogLoadOptions options) throws CatalogInputException
read in interface CatalogInputReaderCatalogInputException