Skip to content

refactor: turn Dialect into a per-driver interface#9149

Open
NamanMahor wants to merge 3 commits intomainfrom
namanmahor/plat-449-refactor-the-dialects-into-the-drivers
Open

refactor: turn Dialect into a per-driver interface#9149
NamanMahor wants to merge 3 commits intomainfrom
namanmahor/plat-449-refactor-the-dialects-into-the-drivers

Conversation

@NamanMahor
Copy link
Copy Markdown
Contributor

@NamanMahor NamanMahor commented Mar 31, 2026

Replace the monolithic Dialect int enum of switch-statement logic in runtime/drivers/olap.go with a Dialect interface. Move shared default implementations into a new runtime/pkg/sqldialect package (Base struct + helpers), and have each OLAP driver own its dialect implementation in a dedicated dialect.go file.

  • runtime/drivers/olap.go: replace Dialect int/constants/methods with a Dialect interface; add DialectName* string constants for comparisons
  • runtime/pkg/sqldialect/base.go: Base struct with virtual dispatch via a local Dispatcher interface (avoids circular import)
  • runtime/pkg/sqldialect/helpers.go: DruidTimeFloorSpecifier, TempName, CheckTypeCompatibility
  • 11 new runtime/drivers/*/dialect.go files, one per driver
  • All callers updated to use Dialect().String() against DialectName* constants instead of comparing int values

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!

NamanMahor and others added 3 commits March 31, 2026 17:57
Replace the monolithic `Dialect int` enum and its ~900 lines of
switch-statement logic in `runtime/drivers/olap.go` with a `Dialect`
interface. Move shared default implementations into a new
`runtime/pkg/sqldialect` package (Base struct + helpers), and have each
OLAP driver own its dialect implementation in a dedicated `dialect.go`
file.

- `runtime/drivers/olap.go`: replace `Dialect int`/constants/methods
  with a `Dialect` interface; add `DialectName*` string constants for
  comparisons
- `runtime/pkg/sqldialect/base.go`: `Base` struct with virtual dispatch
  via a local `Dispatcher` interface (avoids circular import)
- `runtime/pkg/sqldialect/helpers.go`: `DruidTimeFloorSpecifier`,
  `TempName`, `CheckTypeCompatibility`
- 11 new `runtime/drivers/*/dialect.go` files, one per driver
- All callers updated to use `Dialect().String()` against `DialectName*`
  constants instead of comparing int values

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant