refactor: turn Dialect into a per-driver interface#9149
Merged
k-anshul merged 17 commits intoApr 21, 2026
Conversation
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>
…efactor-the-dialects-into-the-drivers
begelundmuller
previously requested changes
Apr 9, 2026
k-anshul
reviewed
Apr 16, 2026
k-anshul
reviewed
Apr 16, 2026
| // For views it returns columns: [View, Create View, character_set_client, collation_connection]. | ||
| // We extract the DDL by column name to avoid depending on column order or count. | ||
| rows, err := db.QueryxContext(ctx, fmt.Sprintf("SHOW CREATE TABLE %s", drivers.DialectMySQL.EscapeTable(table.Database, table.DatabaseSchema, table.Name))) | ||
| rows, err := db.QueryxContext(ctx, fmt.Sprintf("SHOW CREATE TABLE %s", c.Dialect().EscapeTable(table.Database, table.DatabaseSchema, table.Name))) |
Member
There was a problem hiding this comment.
Nit: Directly use DialectMySQL
| // Get row count using SQL query | ||
| var rowCount string | ||
| countQuery := fmt.Sprintf("SELECT COUNT(*) FROM %s", drivers.DialectDuckDB.EscapeIdentifier(table.Name)) | ||
| countQuery := fmt.Sprintf("SELECT COUNT(*) FROM %s", escapeIdentifier(table.Name)) |
Member
There was a problem hiding this comment.
Actually on reflection this will fail for BigQuery and possible Snowflake but lets take it up separately.
…efactor-the-dialects-into-the-drivers
…efactor-the-dialects-into-the-drivers
k-anshul
approved these changes
Apr 21, 2026
pjain1
pushed a commit
that referenced
this pull request
Apr 30, 2026
* refactor: turn `Dialect` into a per-driver interface 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> * move dialect to olap.go * more refactoring * self review * self review * self review 3 * self review 4 * lint * move dialect to dialect.go from olap.go * review comments * review comments * review comment * review comments * review comment --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace the monolithic
Dialect intenum of switch-statement logic inruntime/drivers/olap.gowith aDialectinterface. Move shared default implementations into a newBaseDialectand have each OLAP driver own its dialect implementation in a dedicateddialect.gofile.runtime/drivers/dialect.go: replaceDialect int/constants/methods with aDialectinterface; addDialectName*string constants for comparisons, add BaseDialectruntime/drivers/*/dialect.gofiles, one per driverDialect().String()againstDialectName*constants instead of comparing int valuesCloses PLAT-449: Refactor the dialects into the drivers
Checklist: