Add validate (dry-run) mode to JDBC connection string#234
Conversation
Code Coverage
|
jogrogan
left a comment
There was a problem hiding this comment.
Is the intent for this to supersede SPECIFY mode? We are currently using this as a sort of dry-run via !specify from the cli or internally we call it plan mode. See HoptimatorDdlUtils.specifyFromSql. This mode does not support all SQL types today, notably create view or drop but that seems like a much easier extension than defining a new type.
I was worried about breaking SPECIFY but looks like my VALIDATE just maps to SPECIFY in most cases anyway. sgtm, will tweak. |
@jogrogan looks like SPECIFY and VALIDATE are slightly different after all. SPECIFY doesn't update the internal schema, but VALIDATE does. This is because the For example, consider these two statements: If these are run as separate |
032e631 to
4a9a703
Compare
How would this work in practice? After a validate is complete we don’t want statements to work on a schema that doesn’t actually exist. We would need someway to either issue all validate SQL as a single request or clean up when all validates are done |
Yes, that's why it's a connection property and not a bang command. There is no |
Introduce `mode=validate`, a dry-run flavor alongside `mode=apply`. Every DDL statement (CREATE, DROP, FIRE/PAUSE/RESUME) is fully parsed, planned, and validated — including deployer-level validation — but no real object is created, updated, or deleted. A dry-run still evolves the in-memory Calcite schema so a series of statements validates against each other: e.g. a dry-run DROP VIEW followed by a query against that view fails validation, even though no real View was deleted. To make this explicit, DdlMode's old `mutable()` is split into two axes: `executeDeployers` (the real side effect) and `persistsSchema` (whether in-memory changes are kept). VALIDATE persists schema but deploys nothing; SPECIFY (the `!specify` renderer) restores. With respect to OR REPLACE, validate is apply-like and never errors on an existing object. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
4a9a703 to
db5881f
Compare
| @Override | ||
| boolean shouldRestoreSchema() { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
I believe CREATE and UPDATE still need restore behavior. This is the case where a deployer fails and we need to rollback the in memory map.
Got it, read through the changes and all makes sense now |
|
This PR got a little muddy, so scrapped and rewrote in #235 |
Summary
mode=validateconnection property.Details
Introduce
mode=validate, a dry-run flavor alongsidemode=apply. In validate mode every DDL statement (CREATE,DROP,FIRE/PAUSE/RESUME) is fully parsed, planned, and validated — including deployer-level validation — but no real objects are created, updated, or deleted.With respect to
OR REPLACE, validate behaves like apply: an already-existing object is treated as an in-place update rather than an error. This means validate and apply both have slightly different semantics from the default create mode. Validate and apply are designed for checked-in "as code" DDL files, whereas the default mode is more for typical interactive or imperative API-driven execution.The upshot is that
OR REPLACEis essentially optional in apply mode, and thus also optional in validate mode.Testing Done
Ran the SQL CLI with
mode=validate, which correctly validates but does not actually deploy anything:Notice "dry-run ... skipping deployment" in the output.