การทดสอบ data pipeline ด้วยตนเอง

ETL and ELT ใน Python

Jake Roach

Data Engineer

การทดสอบ data pipeline

data pipeline ควรได้รับการทดสอบอย่างละเอียด

  • ตรวจสอบว่าข้อมูลถูก extract, transform และ load ตามที่คาดไว้

$$

การตรวจสอบขอบเขตของ pipeline ช่วยลดภาระการดูแลหลังจากปรับใช้งาน

  • ระบุและแก้ไขปัญหาคุณภาพข้อมูล
  • เพิ่มความน่าเชื่อถือของข้อมูล

เครื่องมือและเทคนิคสำหรับทดสอบ data pipeline

  • End-to-end testing
  • ตรวจสอบข้อมูลที่ "checkpoint"
  • Unit testing
ETL and ELT ใน Python

สภาพแวดล้อมทดสอบและใช้งานจริง

สภาพแวดล้อมทดสอบและใช้งานจริงสำหรับสร้างและรัน data pipeline

ETL and ELT ใน Python

การทดสอบ pipeline แบบ end-to-end

การทดสอบ data pipeline แบบ end-to-end

End-to-end testing

  • ยืนยันว่า pipeline รันได้สำเร็จทุกครั้งที่ลองซ้ำ
  • ตรวจสอบข้อมูลที่ checkpoint ของ pipeline
  • ทำ peer review และนำข้อเสนอแนะไปปรับใช้
  • มั่นใจว่าผู้ใช้เข้าถึงและพอใจกับผลลัพธ์
ETL and ELT ใน Python

การตรวจสอบ checkpoint ของ pipeline

# Extract, transform, and load data as part of a pipeline
...

# Take a look at the data made available in a Postgres database
loaded_data = pd.read_sql("SELECT * FROM clean_stock_data", con=db_engine)
print(loaded_data.shape)
(6438, 4)
print(loaded_data.head())
         timestamps      volume      open     close                            
1997-05-15 13:30:00  1443120000  0.121875  0.097917
1997-05-16 13:30:00   294000000  0.098438  0.086458
1997-05-19 13:30:00   122136000  0.088021  0.085417
ETL and ELT ใน Python

การตรวจสอบ DataFrame

# Extract, transform, and load data, as part of a pipeline
...

# Take a look at the data made available in a Postgres database
loaded_data = pd.read_sql("SELECT * FROM clean_stock_data", con=db_engine)

# Compare the two DataFrames.
print(clean_stock_data.equals(loaded_data))
True
ETL and ELT ใน Python

มาฝึกกันเถอะ!

ETL and ELT ใน Python

Preparing Video For Download...