Semaine 81 - Tâches et Planification

Saviez-vous qu'une tâche peut avoir plus d'un parent ?

Commencez par accéder au stage suivant, et exécutez directement le fichier qu'il contient avec EXECUTE IMMEDIATE.

CREATE STAGE frosty_aws_stageURL = 's3://frostyfridaychallenges/';

Maintenant, vous devez créer 5 tâches :

La tâche 1 exécutera ce qui suit :

INSERT INTO w81_raw_product (data)SELECT parse_json(column1)FROMVALUES('{"product_id": 21, "product_name": "Product U", "category": "Electronics", "price": 120.99, "created_at": "2024-02-16"}'),('{"product_id": 22, "product_name": "Product V", "category": "Books", "price": 35.00, "created_at": "2024-02-16"}');INSERT INTO w81_raw_customer (data)SELECT parse_json(column1)FROMVALUES('{"customer_id": 6, "customer_name": "Frank", "email": "frank@example.com", "created_at": "2024-02-16"}'),('{"customer_id": 7, "customer_name": "Grace", "email": "grace@example.com", "created_at": "2024-02-16"}');INSERT INTO w81_raw_sales (data)SELECT parse_json(column1)FROMVALUES('{"sale_id": 11, "product_id": 21, "customer_id": 6, "quantity": 1, "sale_date": "2024-02-17"}'), -- Nouveau produit, nouveau client('{"sale_id": 12, "product_id": 22, "customer_id": 1, "quantity": 1, "sale_date": "2024-02-17"}'), -- Nouveau produit, client existant('{"sale_id": 13, "product_id": 2, "customer_id": 7, "quantity": 2, "sale_date": "2024-02-17"}'), -- Produit existant, nouveau client('{"sale_id": 14, "product_id": 3, "customer_id": 6, "quantity": 1, "sale_date": "2024-02-17"}'), -- Produit existant, nouveau client('{"sale_id": 15, "product_id": 21, "customer_id": 5, "quantity": 1, "sale_date": "2024-02-17"}'); -- Nouveau produit, client existant;

Les tâches 2 à 4 analyseront le JSON des tables RAW. (C'est elles que vous voulez créer!)

La tâche 5 exécutera ce qui suit APRÈS que les tâches 2 à 4 aient été terminées :

CREATE OR replace VIEW aggregated_salesASSELECT c.customer_name,p.product_name,SUM(s.quantity) AS total_quantity,SUM(s.quantity * p.price) AS total_salesFROM sales sjoin product pON s.product_id = p.product_idjoin customer cON s.customer_id = c.customer_idGROUP BY c.customer_name,p.product_name


A la fin, vous devrez exécuter:

SELECT t.name,t.predecessorsFROM TABLE(information_schema.Task_dependents(task_name => 'INSERT_INTO_RAW', recursive => TRUE)) t;

Et obtenir:

Bon DAG!

Previous
Previous

Semaine 82 - Débutant

Next
Next

Semaine 81 - Intermédiaire