יצירת מודול של תשתית לנתונים
יצירת מודול מותאם אישית של שכבת נתונים נדרשת רק אם צריך להגדיר התנהגויות מותאמות אישית של בנייה או להרחיב את התמיכה למערכת מקור חדשה (כמו Salesforce) שלא נתמכת מחוץ לקופסה.
לפני שמתחילים, מוודאים שטבלת המקור שרוצים לעבד קיימת במערך הנתונים של שכבת הנתונים הגולמיים.
כשעובדים על מודולים של SAP Data Foundation, צריך לוודא שטבלת DD03L המשוכפלת מכילה את רשומות המטא-נתונים הנדרשות לכל הטבלאות שמתכננים להטמיע (כולל טבלאות מותאמות אישית או טבלאות משלימות). תוכלו למצוא דרישות מפורטות יותר במאמר בנושא דרישות למטא-נתונים של SAP ERP.
כשיוצרים מודול או מרחב שמות מותאמים אישית של שכבת נתונים, מומלץ להשתמש במרחב שמות מותאם אישית ייעודי כדי לשפר את ניהול מחזור החיים על ידי הפרדה בין תוספים והתאמות אישיות לבין ארטיפקטים של 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:
# Recommended naming for foundation_module_id:
# custom_namespace_data_foundation_module_type
- moduleId: foundation_module_id
type: cortex.sap
dataSourceId: sap_raw_s4
dataTargetId: data_foundation_sap_custom_namespace
moduleSettings:
sapVersion: s4
mandt: "100"
# Custom table settings file, relative to 'config/' directory
# If omitted, defaults to "../src/data_modules/custom_namespace/data_foundation/data_foundation_module_type/table_settings.default.yaml"
# tableSettings: "custom_namespace/data_foundation/data_foundation_module_type/table_settings.yaml"
- אפשרות חלופית: אם משתמשים בטבלת CDC חיצונית שעברה עיבוד כבסיס הנתונים, צריך לשנות את הקטע
modules.foundationבקובץconfig/config.yamlל-external: trueולהסיר אתdataTargetId:
data:
modules:
foundation:
- moduleId: foundation_module_id
type: cortex.sap
dataSourceId: sap_raw_s4
external: true
moduleSettings:
sapVersion: s4
mandt: "100"
# Custom table settings file, relative to 'config/' directory
# If omitted, defaults to "../src/data_modules/custom_namespace/data_foundation/data_foundation_module_type/table_settings.default.yaml"
# tableSettings: "custom_namespace/data_foundation/data_foundation_module_type/table_settings.yaml"
- יוצרים את קובץ
tableSettingsשמוזכר בהגדרה, ומגדירים אילו טבלאות ממערך הנתונים של שכבת הנתונים הגולמיים יומרו לשכבת בסיס הנתונים. מומלץ להשתמש בנתיב ברירת המחדל:src/data_modules/custom_namespace/data_foundation/data_foundation_module_type/table_settings.default.yaml
common:
- source:
tableName: custom_sap_table_name
target:
tags: [sap, s4, hourly]
clusterDetails:
columns: [ pk_column]
partitionDetails:
column: fldate
partitionType: time
timeGrain: day
דוגמה למודול של תשתית לנתונים
בדוגמה הבאה נרשם מודול חדש של בסיס נתונים מותאם אישית שמעבד את הטבלה sflight למרחב שמות מותאם אישית sap_bookingdatamodel.
רושמים מודול חדש של 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_bookingdatamodel
moduleSettings:
sapVersion: s4
mandt: "100"
יצירת הקובץ table_settings.default.yaml
יוצרים את קובץ הגדרות הטבלה: src/data_modules/sap_bookingdatamodel/data_foundation/sap/table_settings.default.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"
כדי לוודא שמודול בסיס הנתונים בהתאמה אישית עובר קומפילציה ופריסה בהצלחה, אפשר לעיין בקטע אימות בדף ההרחבות של מוצר הנתונים.
- השלב הקודם: הגדרת מרחב שמות מותאם אישית
- השלב הבא: יצירת מודול של מוצר נתונים
- חזרה לסקירה הכללית