Fusión y consulta de datos de watsonx.data
Aprenda a consultar y fusionar datos de NPSaaS y una tabla de lago de datos.
Antes de empezar
In the examples, the publicly available datos del registro Viaje en taxi a Nueva York {: external} for yellow taxis in January 2021 and 2022 is used. Para seguir este ejemplo, asegúrese de que los datos están en un bucket S3 accesible y la tabla se cargó en watsonx.data en una tabla Apache Iceberg en el servidor Hive Metastore (HMS).
Ejecute una consulta de base de datos cruzada con la tabla en la base de datos del lago de datos.
-
Para identificar qué año tuvo la mayor cantidad de pasajeros, ejecute:
Ejemplo:
LOCALDB.ADMIN(ADMIN)=> select ( select sum(PASSENGER_COUNT) from YELLOW_TAXI_JANUARY_2022_LOADED) as "passengers 2022",( select sum(PASSENGER_COUNT) from MYLAKE.TAXIDATA.YELLOW_TAXI_JANUARY_2021) as "passengers 2021";Salida:
passengers 2022 | passengers 2021 -----------------+----------------- 3324167 | 1794615 (1 row) -
Para comparar cuántos pasajeros viajaron entre la 1:00 AM y las 6:00 PM en 2021 y 2022, ejecute:
Ejemplo:
LOCALDB.ADMIN(ADMIN)=> select(select sum(PASSENGER_COUNT) from YELLOW_TAXI_JANUARY_2022_LOADED where TPEP_PICKUP_DATETIME::time > '1:00am' and TPEP_PICKUP_DATETIME::time < '6:00am') as "overnight passengers 2022", (select sum(PASSENGER_COUNT) from MYLAKE.TAXIDATA.YELLOW_TAXI_JANUARY_2021 where TPEP_PICKUP_DATETIME::time > '1:00am' and TPEP_PICKUP_DATETIME::time < '6:00am') as "overnight passengers 2021";Salida:
overnight passengers 2022 | overnight passengers 2021 ---------------------------+--------------------------- 163058 | 33469 (1 row)