Automate enum sync for spec files - #291
Conversation
jbonofre
left a comment
There was a problem hiding this comment.
Thanks for tackling the enum-sync TODO! I ran the script locally: --check passes on the committed tree, --apply is idempotent, and drift is detected/reconciled correctly. Behavior is solid.
One overall design note plus a few inline comments below. Nothing here is a blocker.
Main point: the per-value descriptions are hardcoded in the script rather than sourced from the schema, so this keeps the values in sync automatically (which is what the TODO asked for) but moves the descriptions sync burden from spec.yaml into the script. See the inline comment for details.
| "schema_path": ["$defs", "Dialect", "enum"], | ||
| "comment_col": 28, | ||
| "header": "# Supported expression language dialects", | ||
| "descriptions": { |
There was a problem hiding this comment.
The per-value descriptions are hardcoded here. osi-schema.json only carries a single description per enum (e.g. "Supported SQL and expression language dialects"), not per-value text — so today they genuinely can't be read from the schema.
Consequence: when a new value is added to the schema, --apply emits it as a bare entry with no comment, and someone has to remember to add its description to this dict. I confirmed this by appending NEWSQL to the schema:
- "BIGQUERY" # Google BigQuery GoogleSQL
- "NEWSQL"So the manual-sync burden isn't eliminated, just relocated. A cleaner long-term design would put per-value descriptions in the schema (single source of truth) and generate both. Not a blocker for this PR — just worth calling out.
There was a problem hiding this comment.
For sure, those appears to be added manually assuming as I was not able to find where they were coming from. Now to your point with add those into the schema, we would need to change the schema here. I think we should start a ML on this before making change here as it is a breaking change due to lack of native per enum value description support. In this case, no change will be apply here and I will start a ML for adding this support. WDYT?
|
Thanks for the review @jbonofre . 4/5 feedbacks had been addressed. Please let me know if we want to proceed with a ML for the enhancement for the last one. |
Summary
The current
core-spec/spec.yamlhas 2 enum sections which would require manual sync fromcore-spec/osi-schema.json. This PR addresses the requested TODO for automating this sync. Also, I removed the TODO annotation and replaced with# Auto-generated from osi-schema.json (xxxx).Things not covered in this PR:
validation/validate.pyis using by checking if a package is importable or not.Sample outputs:
Related Issues
Checklist
Specification
core-spec/and follow the existing structureOntology
ontology/are consistent with spec changesConverters
converters/is updated to reflect spec or ontology changesValidation
validation/are updated if the spec changedDocumentation
docs/is updated to reflect any user-facing changesCONTRIBUTING.mdis updated if the contribution process changedExamples
examples/are added or updated for any new spec constructs or converter supportTests
pytest/ CI green)Compliance