Referencing the base table of a different model

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

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
52/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
静か
技術スタック
python, sql

調査の方向性

The issue points to the @resolve_template macro and the existing implementation for resolving the active model's base table, but names no source files or tests. Start by reading the implementation and tests for @resolve_template, then look for how other models are referenced. Done means a referenced model's base table can be retrieved without hardcoding its fingerprint.

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

説明

I have added primary keys into my SQLMesh models using https://github.com/SQLMesh/sqlmesh/issues/4568 as a guide. The @resolve_template macro is really useful for creating the key on the base table rather than the view.

I would also like to add some foreign keys but I don't think it's possible to get the base table for a different model. For example, this works by hardcoding the referenced table but it will break if the referenced model is ever rebuilt with a different fingerprint:

@IF( @runtime_stage = 'creating', ALTER TABLE @SQL('@this_model') ADD CONSTRAINT @resolve_template('FK_@{table_name}_id') FOREIGN KEY (id) REFERENCES schema._table__fingerprint (id) )

Is it possible to retrieve the base table from a different model in the same way that @resolve_template does for the active model?

Thanks

主要言語
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 を短くまとめたダイジェスト。