Snowsight を使用したセマンティックビューの作成と管理

Snowsight で、セマンティックビュー を作成して管理できます。

セマンティックビューの作成

Snowsight で、ウィザードを使用するか、セマンティックモデル仕様 をアップロードすることで、セマンティックビューを作成できます。

注釈

セマンティックビューを作成するには、セマンティックビューの作成に必要な権限 で説明されている権限を持つロールを使用する必要があります。

Using the AI-assisted generator to create a semantic view

Use the AI-assisted generator to create a semantic view that combines semantic information from multiple sources. Instead of creating a semantic view manually with your own YAML specification, you can use the model generator within Snowsight to save time. The process of creating a semantic view requires the following information:

  • A description with basic information about the view

  • Context, such as example SQL queries

  • The data source (at least one table or view) that you're using

  • The columns that you're using

The AI-assisted generator handles inputs in the following ways:

  • Example SQL queries

    • Validate the list of queries and throw out invalid queries.

    • Extract all tables and columns from the queries and present them for review before adding to the semantic view.

    • Extract relationships from the queries.

    • Add valid queries to the semantic view as verified queries.

  • Table metadata

    • Extract all table and column descriptions.

    • Add primary and unique keys to the semantic view by analyzing metadata or counting distinct values to determine cardinality and relationship types.

  • Query history

    • Surface historical SQL queries as suggestions to the semantic view. The AI-assisted generator identifies the most common types of queries that fit within the bounds of the selected tables and columns.

    • Find valid relationships and column types for the semantic view.

    • Cortex Analyst uses the query history accessible by the role used to create the semantic model to generate both relationships and verified query suggestions.

  1. Snowsight にサインインします。

  2. ナビゲーションメニューで AI & ML » Cortex Analyst を選択します。

  3. At the top of the navigation menu, select Create new » Create new Semantic View.

  4. Select a location to store the semantic view after creation.

  5. Enter a name for the semantic view.

  6. For Description, specify information about the semantic view.

  7. Next を選択します。

  8. To provide context, add the following information:

    • For SQL Queries, provide example questions and their respective SQL queries that you want to use as part of the view.

  9. For Select tables, provide the data source that you're using to create the semantic view.

    You must provide at least one table or view. There's no limit on the tables or views that you can specify, but Snowflake recommends not using more than 10.

  10. Next を選択します。

  11. For Select columns, select the columns that you're using to create the semantic view.

    You can select all the columns or specific columns. For performance reasons, Snowflake recommends not using more than 50 columns.

  12. Select whether you want to add sample values from each column to the semantic view. Sample values help improve the accuracy of Cortex Analyst's results.

  13. Select whether you want to add AI-generated descriptions for tables and columns to the semantic view. The AI-generated descriptions are based on the column names and sample values.

  14. Select Create and save. You can view the progress of the view generation, including details about the steps that the view generator is taking, on the semantic view page. The process can take a few minutes.

  15. Optional: To make additional modifications, edit the view either by using Snowsight or by editing the YAML file directly.

Cortex Analyst automatically generates suggestions to improve the semantic view after creation. After the suggestions appear, which might take several minutes, you can review them and apply them to the view as needed.

セマンティックビューを作成する YAML 仕様のアップロード

  1. Cortex Analyst からセマンティックビューを作成する予定がある場合は、YAML ファイルの ステージを作成 します。

  2. 次のいずれかの方法で YAML ファイルをアップロードします。

    • データベースオブジェクトエクスプローラー:

      1. Snowsight にサインインします。

      2. ナビゲーションメニューで Catalog » Database Explorer を選択します。

      3. セマンティックビューを作成するデータベースとスキーマを選択します。

      4. Create » Semantic View » Upload YAML file を選択します。

      5. アップロードする YAML ファイルを選択します。

      6. Select database, schema and stage で、YAML ファイルをアップロードしたいデータベース、スキーマ、ステージを選択します。

      7. YAML ファイルをステージの特定のパスにアップロードしたい場合は、そのパスを指定します。

      8. Upload を選択します。

    • Cortex Analyst:

      1. Snowsight にサインインします。

      2. ナビゲーションメニューで AI & ML » Cortex Analyst を選択します。

      3. Create new » Upload YAML file を選択します。

      4. アップロードする YAML ファイルを選択します。

      5. Convert and save を選択します。

セマンティックビューの編集

セマンティックビューを編集するには:

  1. 次のいずれかの方法でセマンティックビューにアクセスします。

    • データベースオブジェクトエクスプローラー:

      1. Snowsight にサインインします。

      2. ナビゲーションメニューで Catalog » Database Explorer を選択します。

      3. セマンティックビューを含むデータベースとスキーマを選択します。

      4. Semantic views を選択します。

      5. セマンティックビューを選択します。

      6. Semantic information タブを選択します。

    • Cortex Analyst:

      1. Snowsight にサインインします。

      2. ナビゲーションメニューで AI & ML » Cortex Analyst を選択します。

      3. Semantic views タブを選択します。

      4. Select database to see semantic views で、編集するセマンティックビューを含むデータベースとスキーマを選択します。

      5. 編集するセマンティックビューを選択します。

  2. セマンティックビューに変更を加えます。次のタイプの変更を行うことができます。

    • セマンティックビューの名前や説明を変更するには

      1. セマンティックビューの名前の横にある Edit を選択します。

      2. 名前または説明に変更を加えます。

      3. Apply を選択します。

    • セマンティックビューに新しい論理テーブルを追加するには

      1. データベースオブジェクトエクスプローラーで + Logical Table を選択するか、Cortex Analyst で + を選択します。

      2. ウィザードの Select a table ステップで次を実行します。

        1. セマンティックビューで使用するデータを含むテーブルまたはビューを選択します。

        2. Next を選択します。

      3. ウィザードの Select columns ステップで:

        1. ビューに含める列を選択します。

          テーブルまたは表示内のすべての列を選択するには、テーブルまたはビューを選択します。

        2. Generate logical table を選択します。

    • セマンティックビューで論理テーブルの名前、説明、同義語、または主キーを変更するには

      1. データベースオブジェクトエクスプローラーの論理テーブル名の横にある その他のオプション » Edit Logical Table、または Cortex Analyst の論理テーブル名の横にある Edit を選択します。

      2. 名前、説明、同義語、主キーを変更します。

        説明や同義語を指定していない場合は、Generate fields を選択するとこれらのフィールドに自動入力できます。

      3. Save を選択します。

    • ファクト、ディメンション、またはメトリックを追加するには

      1. 新しいアイテムを追加するフォームを開きます。

        • データベースオブジェクトエクスプローラーで、その他のオプション を選択してから、FactDimension、または Metric を選択します。

        • Cortex Analyst で、FactsDimensions、または Metrics の横にある + を選択します。

      2. 新しいファクト、ディメンション、またはメトリックに関する情報を入力し、Add を選択します。

    • ファクト、ディメンション、またはメトリックを変更または削除するには

      1. FactsDimensions、または Metrics を選択して、ファクト、ディメンション、またはメトリックのリストを表示します。

      2. 変更するファクト、ディメンション、またはメトリックについて

        • Edit を選択してアイテムを変更します。

        • その他のオプション»Remove factRemove dimension、または:ui:Remove metric を選択してアイテムを削除します。

    • 関係を追加するには

      1. 新しいアイテムを追加するフォームを開きます。

        • データベースオブジェクトエクスプローラーで、+ Relationship を選択します。

        • Cortex Analyst で、Relationships の横にある + を選択します。

      2. 関係の名前を入力し、関係内のテーブルを選択して、テーブルの結合に使用する列を選択します。

      3. Add を選択します。

  3. このビューで Cortex Analyst を使用する予定がある場合は、次のことを考慮します。

    • Verified Queries セクションにサンプルクエリを追加します。このセクションは Cortex Analyst でのみ利用可能です。

      • これらは、Cortex Analystがセマンティックビューの使い方を理解するのに役立つクエリ例です。

      • データの一般的な使用ケースを表すクエリを追加します。

    • テーブル、ファクト、ディメンジョン、またはメトリクスの同義語を追加します。

      • これらは、ユーザーがクエリで使用する可能性のある代替用語です。

      • 同義語は、 Cortex Analyst が、ユーザーの質問を正しく解釈するのに役立ちます。

    • カスタム指示を追加します。

      • これらは、データをどのように解釈すべきかについての追加的なコンテキストを提供します。

      • 考慮すべきビジネスルールや制約を含めてください。

  4. Save を選択します。

セマンティックビューを使用する権限の別のロールへの付与

セマンティックビューの表示とクエリの権限を別のロールに付与するには

  1. 次のいずれかの方法でセマンティックビューにアクセスします。

    • データベースオブジェクトエクスプローラー:

      1. Snowsight にサインインします。

      2. ナビゲーションメニューで Catalog » Database Explorer を選択します。

      3. セマンティックビューを含むデータベースとスキーマを選択します。

      4. Semantic views を選択します。

      5. セマンティックビューを選択します。

      6. その他のオプション » Share を選択します。

    • Cortex Analyst:

      1. Snowsight にサインインします。

      2. ナビゲーションメニューで AI & ML » Cortex Analyst を選択します。

      3. Semantic views タブを選択します。

      4. セマンティックビューを選択します。

      5. Share を選択します。

  2. セマンティックビューの表示とクエリの権限を付与するロールを選択します。

  3. Done を選択します。

これによりセマンティックビューに関する SELECT と REFERENCES の権限を選択したロールに付与します。

セマンティックビューのクエリ

データベースオブジェクトエクスプローラーでセマンティックビューを表示している場合は、その他のオプション » Query with SQL を選択すると、ワークシートを開いてそのビューのクエリを構築することができます。

クエリを構築する方法については、セマンティックビューのクエリ をご参照ください。

セマンティックビュー作成のベストプラクティス

  • 明確な説明を提供します:

    • すべての名称と説明にはビジネス用語を使用してください。

    • 技術的な知識がないユーザーでも理解できるように、説明を詳しくしてください。

  • 代表的なユーザーの質問を含みます:

    • モデルジェネレーターがあなたの意図をよりよく理解するのに役立つ質問を含めてください。

    • 質問の仕方のバリエーションを含めてください。

  • 生成された提案を注意深く検討してください:

    • 質問がユースケースに関連していることを確認してください。

    • 提案された関係があなたのビジネスの理解に合致していることを確認してください。

  • 実際の問題でテストします:

    • セマンティックビューを作成したら、実際のビジネス質問でテストしてみましょう。

    • モデルがこれらの質問をどの程度サポートしているかに基づいて、セマンティックビューを絞り込みます。

  • セマンティックビューの開発を繰り返す:

    • シンプルなスタースキーマから始めましょう。

    • 中核となるテーブルと測定基準から始め、その後拡張していきます。シンプルにするために、3つのテーブルをお勧めします。

    • ビジネスユーザーからフィードバックを得て、セマンティックビューを改善しましょう。

トラブルシューティング

  • セマンティックビューがビューのリストに記載されていない場合は、モデルのリスト(ページ自体ではなく)を更新します。

  • セマンティックビューのリレーションシップでエラーが発生した場合は、これらのリレーションシップが実際のデータ構造と一致していることを確認してください。

  • クエリが遅い場合は、テーブルや列の数を減らしてください。

  • Cortex Analyst に、セマンティック・ビューを使用した際に予期しない結果が表示された場合は、セマンティック・ビューのファクト、ディメンジョン、メトリクスを見直してください。