יצירת מודול של תשתית לנתונים
כדי לעבד טבלאות גולמיות משלימות ולכלול אותן במערך נתוני היסוד, צריך ליצור מודול data foundation.
כשיוצרים מודול מותאם אישית של שכבת נתונים, מומלץ להשתמש במרחב שמות מותאם אישית ייעודי כדי לארוז אותו. בנוסף, צריך לוודא שטבלת המקור שאתם מתכננים לעבד קיימת במערך הנתונים של שכבת הנתונים הגולמיים.
כשעובדים על מודולים של SAP Data Foundation, צריך לוודא שהטבלה DD03L שוכפלה במערך הנתונים הגולמי – שמוגדר כמקור למודול ה-Foundation בקובץ config/config.yaml. בנוסף, צריך לוודא שטבלת 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
- כדי להגדיר את מודול שכבת הנתונים, מוסיפים את הקוד הבא לקטע
modules.foundationבקובץconfig/config.yaml:
[...]
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 חיצונית שעברה עיבוד כבסיס לנתונים, צריך לשנות את הקטע
modules.foundationבקובץconfig/config.yamlל-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 Foundation.
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"
כדי לוודא שמודול בסיס הנתונים בהתאמה אישית עובר קומפילציה ופריסה בהצלחה, אפשר לעיין בקטע אימות בדף ההרחבות של מוצר הנתונים.
- השלב הקודם: הגדרת מרחב שמות מותאם אישית
- השלב הבא: יצירת מודול של מוצר נתונים
- חזרה לסקירה הכללית