データ基盤モジュールの作成

補足的な元テーブルを処理してデータ基盤データセットに含めるには、データ基盤モジュールを作成する必要があります。

カスタム データ基盤モジュールを作成する場合は、専用のカスタム名前空間を使用してパッケージ化することをおすすめします。また、処理する予定のソーステーブルが元レイヤ データセットに存在することを確認してください。

SAP データ基盤モジュールを使用する場合は、config/config.yaml ファイルで基盤モジュールのソースとして構成されている元データセットに DD03L テーブルがレプリケートされていることを確認してください。また、レプリケートされた DD03L テーブルに、取り込む予定のテーブル(sflight などのカスタムテーブルや補足テーブルなど)のフィールド メタデータ レコードが含まれていることを確認してください。Cortex Framework のビルド スクリプトと依存関係リゾルバは、これらのメタデータ行を読み取って、テーブル間の列リスト、データ型、主キーの関係を特定します。

データ基盤モジュールの定義

データ基盤モジュールを定義する手順は次のとおりです。

  • config/config.yaml ファイルで、ターゲット データセット構成を data.targets に追加します。これにより、基盤テーブルがデプロイされる専用の BigQuery データセットが準備されます。
[...]
data:
  [...]
  targets:
    - id: data_foundation_sap_custom_namespace
      # Google Cloud Project ID for the target dataset.
      projectId:  target_project_id 
      # BigQuery dataset ID for the target.
      datasetId: data_foundation_sap_custom_namespace   
  • データ基盤モジュールを定義するには、config/config.yaml ファイルの modules.foundation セクションに以下を追加します。
[...]
data:
  [...]
  modules:
    foundation:
      [...]
      - moduleId:  foundation_module_id 
        type: cortex.sap
        dataSourceId: sap_raw_s4
        dataTargetId: data_foundation_sap_custom_namespace
        moduleSettings:
          sapVersion: s4
          mandt: "100"
        tableSettings: "table_settings.yaml"
        # Optional. Path to custom table settings configuration relative to this config file, e.g., `config/custom_namespace_path/data_foundation/sap/table_settings.yaml`
        # If omitted, defaults to src/data_modules/cortex/data_foundation/sap/table_settings.default.yaml. 

  • 代替方法: 外部処理された CDC テーブルをデータ基盤として使用する場合は、config/config.yaml ファイルの modules.foundation セクションを external: true に調整し、targetDataSetID を削除します。
[...]
data:
  [...]
  modules:
    foundation:
      [...]
      - moduleId:  foundation_module_id 
        type: cortex.sap
        dataSourceId: sap_raw_s4
        external: true
        moduleSettings:
          sapVersion: s4
          mandt: "100"
        tableSettings: "table_settings.yaml"
        # Optional. Path to custom table settings configuration relative to this config file, e.g., `config/custom_namespace_path/data_foundation/sap/table_settings.yaml`
        # If omitted, defaults to src/data_modules/cortex/data_foundation/sap/table_settings.default.yaml. 

  • 参照される table_settings.yaml を作成して、元レイヤ データセットのどのテーブルをデータ基盤レイヤに変換するかを定義します。
common:
  - source:
      tableName: custom_sap_table_name
    target:
      tags: [sap, s4, hourly]
      clusterDetails:
        columns: [carrid, connid]
      partitionDetails:
        column: fldate
        partitionType: time
        timeGrain: day

データ基盤モジュールの例

次の例では、事前に定義した名前空間 custom_namespace を使用して、sflight テーブルを処理する新しいカスタム データ基盤モジュールを作成します。

新しいデータ基盤モジュールを登録する。

data:
  targets:
    - id: data_foundation_sap_bookingdatamodel
      projectId:  target_project_id
      datasetId: data_foundation_sap_bookingdatamodel   
  modules:
    foundation:
      - moduleId:  sap_bookingdatamodel
        type: sap_bookingdatamodel.sap
        dataSourceId: sap_raw_s4
        dataTargetId: data_foundation_sap_sap_bookingdatamodel
        moduleSettings:
          sapVersion: s4
          mandt: "100"
        tableSettings: "table_settings.yaml"

table_settings.yaml を作成する

次の内容でファイル config/sap_bookingdatamodel/data_foundation/sap/table_settings.yaml を作成します。

common:
  - source:
      tableName: sflight
    target:
      tags: [sap, s4, hourly]
      clusterDetails:
        columns: [carrid, connid]
      partitionDetails:
        column: fldate
        partitionType: time
        timeGrain: day

このテーブルは SAP ECC と S/4HANA の両方で同じレイアウトであるため、common: セクションの子要素です。

各テーブルのアノテーション ファイルを作成して、スキーマにメタデータを追加します。

サンプル シナリオでは、次の内容で src/data_modules/sap_bookingdatamodel/data_foundation/sap/annotations/sflight.yaml を作成します。

description: "transparent table FLIGHT, part of the Basis Components Module, BC-DWB-TND (Training and Demo)."
fields:
- name: "mandt"
  description: "Client"
- name: "carrid"
  description: "Airline Code"
- name: "connid"
  description: "Flight Connection Number"
- name: "fldate"
  description: "Flight date"
- name: "price"
  description: "Airfare"
- name: "currency"
  description: "Local currency of airline"
- name: "planetype"
  description: "Aircraft Type"
- name: "seatsmax"
  description: "Maximum capacity in economy class"
- name: "seatsocc"
  description: "Occupied seats in economy class"
- name: "paymentsum"
  description: "Total of current bookings"
- name: "seatsmax_b"
  description: "Maximum capacity in business class"
- name: "seatsocc_b"
  description: "Occupied seats in business class"
- name: "seatsmax_f"
  description: "Maximum capacity in first class"
- name: "seatsocc_f"
  description: "Occupied seats in first class"

カスタム データ基盤モジュールがコンパイルされて正常にデプロイされることを確認するには、データ プロダクトの拡張機能ページの検証セクションをご覧ください。