Oracle engine adapter: scope proposal before implementation

オープン
#6,048 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 4 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
15/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
python, sql
領域
backend, databases

調査の方向性

Start by reading the proposed adapter constraints and the named entry points, especially sqlmesh/utils/migration.py and FORBIDDEN_STATE_SYNC_ENGINES; inspect SQLMesh’s existing engine adapters and SQLGlot’s Oracle dialect. The issue asks maintainers to decide scope, ownership, review split, CI, and dependency sequencing before implementation, so there is no implementation task or completion criterion yet.

索引モデルが issue の本文から書いたものです。

説明

I would like to implement an Oracle engine adapter and contribute it upstream. Before writing
several thousand lines, I want to agree the scope with the maintainers, since Oracle has a number
of semantics that force product-visible decisions rather than purely internal ones.

Three earlier requests were closed as not planned with an invitation to contribute: #2156
("happy to work with someone to add it"), #2784 ("happy to accept a well crafted and tested PR"),
and #2236 ("happy to partner with a company interested in oracle"). I am picking this up on that
basis. As far as I can tell nobody is currently working on it — please tell me if that is wrong.

What I propose to build

An OracleEngineAdapter targeting Oracle 19c and above, with Oracle usable as a data warehouse
only.

Scope decisions I have provisionally made, with the reasoning:

State sync in Oracle: out of scope. index_text_type (sqlmesh/utils/migration.py) has no
Oracle entry, so _snapshots columns name, identifier, version and dev_version would be
generated as CLOB. Oracle does not permit CLOB in a primary key and does not support equality
on CLOB, so the state schema cannot be created at all. Validating the 87+ migrations against a
live Oracle is a body of work comparable to the adapter itself. I propose adding oracle to
FORBIDDEN_STATE_SYNC_ENGINES for the first version, with state kept in Postgres or DuckDB.

Model kinds in v1: FULL, VIEW, EMBEDDED, INCREMENTAL_BY_TIME_RANGE, INCREMENTAL_BY_UNIQUE_KEY.
INCREMENTAL_BY_PARTITION is excluded because SQLGlot has no Oracle partitioning support at all.
MANAGED is excluded. SCD_TYPE_2 depends on how MERGE is resolved (see below).

Schema creation. In Oracle a schema is a user; CREATE SCHEMA does not create a schema in any
version, including 26ai. Creating one requires CREATE USER ... GRANT ..., plus a tablespace quota
or GRANT UNLIMITED TABLESPACE, otherwise the first insert fails with ORA-01950.

Whether SQLMesh can do that itself depends on the deployment. In a multitenant setup — the norm on
19c, where non-CDB is deprecated — DBA is commonly granted PDB-locally
(GRANT DBA TO app_owner CONTAINER=CURRENT), which does not touch the CDB or sibling PDBs. Teams
that get their own PDB, and Autonomous Database users who get ADMIN, can create users freely.
Where the service account is a restricted local user in a shared PDB, they cannot.

So I propose the adapter detects rather than assumes: check SESSION_PRIVS for CREATE USER and
create schemas on the fly when the privilege is present, matching SQLMesh's behaviour on every
other engine; otherwise fail with a clear error naming the schemas a DBA has to pre-create. I would
like your view on whether that detection belongs in the adapter or should be an explicit
configuration option.

MERGE. Oracle MERGE does not support WHEN NOT MATCHED BY SOURCE, does not allow updating
join key columns, and permits exactly one WHEN MATCHED and one WHEN NOT MATCHED clause. So
neither the base merge() nor the MSSQL-style implementation transfers. The options are a custom
merge() or LogicalMergeMixin (delete + insert). The latter is slower but much simpler and would
bring SCD_TYPE_2 along nearly for free.

Upstream SQLGlot work

Some of this cannot be fixed in the adapter because it leaks into user model SQL. The Oracle
dialect currently emits SQL that is invalid on 19c:

  • No BOOLEAN mapping in TYPE_MAPPING; 19c and 21c have no column-level BOOLEAN type at all
  • MINUS is tokenized to TokenType.EXCEPT but never generated back, so an Oracle-to-Oracle
    round trip of MINUS produces EXCEPT, which is invalid before 23ai
  • The VALUES table constructor is emitted verbatim; it does not exist before 23ai

SQLGlot already supports per-version dialect branching — SUPPORTED_SETTINGS includes version,
and postgres, duckdb, spark and clickhouse branch on self.dialect.version — but the Oracle
dialect does not use it. So these can be fixed properly rather than by picking one target version.

Note that IF [NOT] EXISTS was backported to 19c in RU 19.28, so that particular gap has a
version threshold rather than a hard floor.

Questions

  1. Is the scope above acceptable in principle, in particular state sync being out of scope and
    schemas needing to pre-exist?
  2. Does this need a TSC decision, or is a maintainer sign-off enough?
  3. How would you like the work split for review? The StarRocks contribution (#5832) landed as a
    single 25-file PR. I can follow that shape, or split adapter, tests, CI and docs.
  4. Is CI time a concern? gvenzl/oracle-free:23-slim-faststart is about 1.2 GB compressed and one
    container, which is lighter than the Trino stack already running per PR, but Oracle Free is
    capped at 2 CPU threads and 2 GB SGA, so the integration suite will be slower than other engines.
  5. Would you prefer the SQLGlot changes to land first, or in parallel with the adapter?
  6. What is the expectation for sqlglot~=30.8.0 in pyproject.toml if the dialect fixes land in
    a later SQLGlot release?

Happy to adjust any of this. If there is prior context from the earlier sponsorship discussion
mentioned in #2236, I would like to know it before starting.

主要言語
Python
スター
3.3k
フォーク
471
平均マージ
6日 7時間
マージ済み PR(30日)
35

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

SQLMesh/sqlmesh のほかの issue

SQLMesh/sqlmesh の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。