Question 166

A data analyst has provided a data engineering team with the following Spark SQL query:
1.SELECT district,
2.avg(sales)
3.FROM store_sales_20220101
4.GROUP BY district;
The data analyst would like the data engineering team to run this query every day. The date at the end of the
table name (20220101) should automatically be replaced with the current date each time the query is run.
Which of the following approaches could be used by the data engineering team to efficiently auto-mate this
process?
  • Question 167

    The view updates represents an incremental batch of all newly ingested data to be inserted or updated in the customers table.
    The following logic is used to process these records.
    MERGE INTO customers
    USING (
    SELECT updates.customer_id as merge_ey, updates .*
    FROM updates
    UNION ALL
    SELECT NULL as merge_key, updates .*
    FROM updates JOIN customers
    ON updates.customer_id = customers.customer_id
    WHERE customers.current = true AND updates.address < > customers.address ) staged_updates ON customers.customer_id = mergekey WHEN MATCHED AND customers. current = true AND customers.address < > staged_updates.
    address THEN
    UPDATE SET current = false, end_date = staged_updates.effective_date
    WHEN NOT MATCHED THEN
    INSERT (customer_id, address, current, effective_date, end_date)
    VALUES (staged_updates.customer_id, staged_updates.address, true, staged_updates.effective_date, null) Which statement describes this implementation?