Skip to content

SPI foundation: replace java.sql.Connection with DeploymentContext - #240

Merged
jogrogan merged 1 commit into
mainfrom
jogrogan/decouple-pr1-spi
Jul 27, 2026
Merged

SPI foundation: replace java.sql.Connection with DeploymentContext#240
jogrogan merged 1 commit into
mainfrom
jogrogan/decouple-pr1-spi

Conversation

@jogrogan

Copy link
Copy Markdown
Collaborator

Decouple Proteus DDL

Hoptimator's validation and deployment logic is currently reachable only by issuing SQL DDL through a Calcite/JDBC connection. That couples every caller to Calcite and forces schema definitions through a lossy  Avro → RelDataType → Avro  round-trip. Hoptimator via a CLI or over REST/gRPC may want to create/validate tables by handing us a table name + a schema directly — not by constructing DDL.

This stacked series decouples the validators and deployers from Calcite so the same validation and deployment engine can be driven either by SQL or by a direct, connection-free call — while keeping validators/deployers as a clean SPI. The payoff: an API call to "create table from a schema" path with identical guarantees to DDL (including dry-run), lossless Avro fidelity, and no Calcite dependency for callers that don't want one. It also keeps the door open for follow-ups (e.g. materializations, source→sink field mappings) without re-plumbing.

Stacked series (review/merge in order):

  1.  decouple-pr1-spi  — SPI foundation:  java.sql.Connection  →  DeploymentContext  (pure decoupling, no behavior change)
  2.  decouple-pr2-api  — SQL-free  TableService  + lossless Avro preservation
  3.  decouple-pr3-hardening  — typed transient failures + required  Deployer.exists() 
    (This is PR 1 of 3.)

PR 1/3 — SPI foundation: replace java.sql.Connection with DeploymentContext

Today the deploy/validate SPI is threaded with java.sql.Connection, which hard-wires the
control plane to Calcite/JDBC. That makes it impossible to drive table validation and
creation any way other than through a JDBC connection running DDL. This PR introduces a
neutral seam — DeploymentContext — and moves the entire SPI and every deployer off
java.sql.Connection, without changing any behavior. It is pure decoupling: the
SQL/DDL path works exactly as before, just over the new context instead of a connection.

This is the groundwork for a SQL-free, connection-free table API (PR2), which in turn
lets callers (e.g. a gRPC service) request the same validation + deployment from a table
path and a schema rather than by issuing DDL.

What changes

  • New SPI type DeploymentContext (hoptimator-api) — the connection-free handle the
    deploy/validate machinery now depends on, replacing java.sql.Connection across
    Deployer, Validator, Connector, and the *Provider interfaces.
  • CalciteDeploymentContext — the SQL-path implementation that adapts the existing
    Calcite/JDBC world onto DeploymentContext, so the DDL path is unchanged.
  • DualLogger extracted from HoptimatorConnection — log-hook fan-out is no longer
    tied to the connection object.
  • SimpleDeploymentContext — a minimal context for connection-free control-plane
    callers.
  • databaseProperties(...) now takes optional catalog/schema, so config resolution
    no longer assumes a fully-qualified JDBC identifier.
  • All deployers migrated off java.sql.Connection — K8s (and its YAML/job/source/MV
    deployers), Kafka, MySQL, Venice, and the logical-table deployer — plus the
    Config/Connector/Validator providers.
  • HoptimatorDdlUtils refactored to drive deployment through the context rather than the
    connection.

What this PR does not do

  • No direct/SQL-free table API yet (that's PR2).
  • No Avro schema preservation (PR2).
  • No behavior changes to validation, deployment, or DDL semantics.

Testing

  • Unit suite green (deployer/provider/service tests updated to the new context; new
    DualLoggerTest, SimpleDeploymentContextTest, TestDeploymentContext).
  • Existing integration behavior unchanged — the SQL/DDL path is exercised as before.

Review notes

  • ~118 files, but the vast majority are mechanical Connection → DeploymentContext
    signature swaps in deployers/providers and their tests.
  • The conceptual core is DeploymentContext, CalciteDeploymentContext, DualLogger, and
    the HoptimatorDdlUtils refactor; the rest follows from those.
  • Docs updated: docs/extending/validators.md.

@jogrogan
jogrogan force-pushed the jogrogan/decouple-pr1-spi branch from 25693de to a4b5fff Compare July 27, 2026 19:44
Introduce a neutral DeploymentContext SPI and migrate the deploy/validate
machinery (Deployer/Validator/Connector/Config providers) plus all deployers
off java.sql.Connection. Adds CalciteDeploymentContext (SQL path), DualLogger
(extracted from HoptimatorConnection), SimpleDeploymentContext, and makes
databaseProperties' catalog/schema optional. The SQL/DDL path is fully on
DeploymentContext; no direct table API or Avro preservation yet.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jogrogan
jogrogan force-pushed the jogrogan/decouple-pr1-spi branch from a4b5fff to da168a3 Compare July 27, 2026 20:19
@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown

Code Coverage

Overall Project 84.49% -0.81% 🟢
Files changed 81.92% 🟢

File Coverage
HoptimatorJdbcCatalogSchema.java 100% 🟢
RemoteToEnumerableConverterRule.java 100% 🟢
HoptimatorJdbcConvention.java 100% 🟢
MySqlDeployerProvider.java 100% 🟢
Validator.java 100% 🟢
ConfigService.java 100% 🟢
ConnectionService.java 100% 🟢
SimpleDeploymentContext.java 100% 🟢
ValidationService.java 100% 🟢
DualLogger.java 100% 🟢
DefaultValidatorProvider.java 100% 🟢
CompatibilityValidatorProvider.java 100% 🟢
CalciteDeploymentContext.java 100% 🟢
SystemPropertiesConfigProvider.java 100% 🟢
K8sDependencyValidator.java 100% 🟢
K8sJobDeployer.java 100% 🟢
K8sValidatorProvider.java 100% 🟢
K8sConfigProvider.java 100% 🟢
K8sDeployerProvider.java 100% 🟢
K8sDatabaseTable.java 100% 🟢
K8sConnectorProvider.java 100% 🟢
AvroValidatorProvider.java 100% 🟢
VeniceDeployerProvider.java 100% 🟢
LogicalTableDeployerProvider.java 100% 🟢
KafkaDeployerProvider.java 100% 🟢
DeployerUtils.java 97.96% 🟢
K8sConnector.java 97.85% 🟢
AvroConverter.java 97.56% -0.44% 🟢
KafkaDeployer.java 97.11% 🟢
MySqlDeployer.java 96.74% -0.15% 🟢
PipelineRel.java 95.89% 🟢
K8sMaterializedViewDeployer.java 95.85% 🟢
HoptimatorJdbcSchema.java 95.74% 🟢
AvroTableValidator.java 95.62% 🟢
K8sSourceDeployer.java 95.43% 🟢
K8sViewTable.java 95.42% 🟢
DeploymentService.java 94.52% 🟢
K8sDeployer.java 92.97% -7.03% 🟢
HoptimatorDriver.java 90.8% -2.99% 🟢
K8sCatalog.java 89.09% 🟢
HoptimatorConnection.java 87.76% -4.48%
HoptimatorDdlUtils.java 85.96% -4.46% 🟢
HoptimatorDdlExecutor.java 85.73% -1.12% 🟢
K8sGraphProvider.java 83.75% 🟢
K8sYamlDeployer.java 83.33% -16.67%
K8sContext.java 81.74% 🟢
CompatibilityValidatorBase.java 81.69% 🟢
LogicalTableDeployer.java 75.45% -6.93%
LogicalTableDriver.java 70.8% -5.84%
PipelineOperatorApp.java 67.84% -0.75%
HoptimatorMcpServer.java 62.78% -1.91%
VeniceDeployer.java 55.47% -2.5%
EngineRules.java 40% 🟢
RemoteToEnumerableConverter.java 1.52% -2.58%
Deployer.java 0%

@ryannedolan ryannedolan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love it

Comment on lines +122 to +123
* Builds the effective JDBC URL for a Database: its CRD {@code url} with the connection-level
* properties (except {@code user}/{@code password}) and the CRD name appended as

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude loves to conflate CRD with CR (everyone does).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea that's fair, did a quick check and it seems to be conflating in a bunch of spots, many already checked in. I'll try to clean it up separate from this.

@jogrogan
jogrogan merged commit e7ae23d into main Jul 27, 2026
1 check passed
@jogrogan
jogrogan deleted the jogrogan/decouple-pr1-spi branch July 27, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants