use-cases/lambda-chaining-with-redshift-data-api/cloud_formation_template/lambda-chaining-with-redshift-data-api.yaml [379:416]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            else:
              sql_text = '''
                      CREATE TABLE IF NOT EXISTS nyc_yellow_taxi
                      (pickup_date        DATE
                      , pickup_datetime  TIMESTAMP
                      , dropoff_datetime TIMESTAMP
                      , ratecode         SMALLINT
                      , passenger_count  SMALLINT
                      , trip_distance    FLOAT4
                      , fare_amount      FLOAT4
                      , total_amount     FLOAT4
                      , payment_type     SMALLINT
                      , vendorid         VARCHAR(20))
                      SORTKEY(pickup_date);
                      DROP MATERIALIZED VIEW IF EXISTS  nyc_yellow_taxi_volume_analysis;
                      CREATE MATERIALIZED VIEW nyc_yellow_taxi_volume_analysis
                      AS
                      SELECT
                        DATE_TRUNC('mon',pickup_date) pickup_month
                      , ROUND(AVG(trip_distance),2) avg_distance
                      , ROUND(AVG(fare_amount),2) avg_fare
                      , COUNT(1) total_trips
                      , SUM(trip_distance) total_distance_per_month
                      , SUM(fare_amount) total_fare_per_month
                      FROM nyc_yellow_taxi
                      GROUP BY 1;
                      CREATE OR REPLACE PROCEDURE run_elt_process()
                      AS $$
                      BEGIN
                        truncate table nyc_yellow_taxi;
                        COPY nyc_yellow_taxi FROM 's3://event-driven-app-with-lambda-redshift/nyc_yellow_taxi_raw/'
                        IAM_ROLE '{}'
                        region 'us-west-2' delimiter '|';
                        REFRESH MATERIALIZED VIEW nyc_yellow_taxi_volume_analysis;
                      END;
                      $$ LANGUAGE plpgsql;
                      '''
              sql_text = sql_text.format(redshift_cluster_iam_role)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



use-cases/lambda-chaining-with-redshift-data-api/scripts/LambdaRedshiftSetupObjects.py [28:65]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        else:
            sql_text = '''
                      CREATE TABLE IF NOT EXISTS nyc_yellow_taxi
                      (pickup_date        DATE
                      , pickup_datetime  TIMESTAMP
                      , dropoff_datetime TIMESTAMP
                      , ratecode         SMALLINT
                      , passenger_count  SMALLINT
                      , trip_distance    FLOAT4
                      , fare_amount      FLOAT4
                      , total_amount     FLOAT4
                      , payment_type     SMALLINT
                      , vendorid         VARCHAR(20))
                      SORTKEY(pickup_date);
                      DROP MATERIALIZED VIEW IF EXISTS  nyc_yellow_taxi_volume_analysis;
                      CREATE MATERIALIZED VIEW nyc_yellow_taxi_volume_analysis
                      AS
                      SELECT
                        DATE_TRUNC('mon',pickup_date) pickup_month
                      , ROUND(AVG(trip_distance),2) avg_distance
                      , ROUND(AVG(fare_amount),2) avg_fare
                      , COUNT(1) total_trips
                      , SUM(trip_distance) total_distance_per_month
                      , SUM(fare_amount) total_fare_per_month
                      FROM nyc_yellow_taxi
                      GROUP BY 1;
                      CREATE OR REPLACE PROCEDURE run_elt_process()
                      AS $$
                      BEGIN
                        truncate table nyc_yellow_taxi;
                        COPY nyc_yellow_taxi FROM 's3://event-driven-app-with-lambda-redshift/nyc_yellow_taxi_raw/'
                        IAM_ROLE '{}'
                        region 'us-west-2' delimiter '|';
                        REFRESH MATERIALIZED VIEW nyc_yellow_taxi_volume_analysis;
                      END;
                      $$ LANGUAGE plpgsql;
                      '''
            sql_text = sql_text.format(redshift_cluster_iam_role)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



