Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Provides data engineering patterns for ETL pipelines, data warehousing, Apache Spark, and data quality validation.
45% 68%+23 ptsof test cases passed
Passed 15 of 22 test cases with the skill, and 10 of 22 without it.
We are writing a Python transformation function for incoming order dicts containing key total. What numeric threshold should be evaluated to assign a boolean is_high_value field on each record?
Evaluates total amount greater than 1000 to set is_high_value flag
3 of 3 safety checks passed
from datetime import datetime
from dataclasses import dataclass
@dataclass
class PipelineResult:
records_extracted: int
records_transformed: int
records_loaded: int
errors: list[str]
duration_seconds: float
class OrderPipeline:
def __init__(self, source_db, warehouse_db):
self.source = source_db
self.warehouse = warehouse_db
def extract(self, since: datetime) -> list[dict]:
query = """
SELECT o.*, c.name as customer_name, c.segment
FROM orders o
JOIN customers c ON o.customer_id = c.id
WHERE o.updated_at > %s
"""
return self.source.fetch_all(query, [since])
def transform(self, records: list[dict]) -> list[dict]:
transformed = []
for record in records:
transformed.append({
"order_id": record["id"],
"customer_name": record["customer_name"],
"segment": record["segment"].upper(),
"total_amount": float(record["total"]),
"order_date": record["created_at"].date(),
"fiscal_quarter": get_fiscal_quarter(record["created_at"]),
Next to this one in the catalogue, plus more from the same author.