0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Google Skills Boost "Engineer Data in Google Cloud" コンプリートを目指して

Last updated at Posted at 2022-06-30

このクエストの最後のGoogle Cloud でのデータ エンジニアリング: チャレンジラボ を実施してみます。

... 勉強が足りないのに無謀でした。最初のタスクすら完了できませんでした。

しまった。途中のSQL文だけでも書いておけばよかった。

自分が考えたのがこれ。

UPDATE taxirides.taxi_training_data_789 t1
SET
pickup_datetime = t0.pickup_datetime,
pickuplon = t0.pickup_longitude,
pickuplat = t0.pickup_latitude ,
dropofflon = t0.dropoff_longitude,
dropofflat = t0.dropoff_latitude,
passengers = t0.passenger_count,
fare_amount_810 = ( t0.tolls_amount + t0.fare_amount )
FROM
taxirides.historical_taxi_rides_raw t0
WHERE
t0.trip_distance > 0
AND t0.fare_amount >= 2.5
AND t0.pickup_longitude > -75
AND t0.pickup_longitude < -73
AND t0.dropoff_longitude > -75
AND t0.dropoff_longitude < -73
AND t0.pickup_latitude > 40
AND t0.pickup_latitude < 42
AND t0.dropoff_latitude > 40
AND t0.dropoff_latitude < 42
AND t0.passenger_count > 0

変更されたのが0件だった。

正しくは、クエリのオプションを「クエリ結果の宛先テーブルを設定する」にしておき、以下のクエリーで検索結果がtaxirides.taxi_training_data_789 に入るようにする。

Select
pickup_datetime,
pickup_longitude AS pickuplon,
pickup_latitude AS pickuplat,
dropoff_longitude AS dropofflon,
dropoff_latitude AS dropofflat,
passenger_count AS passengers,
( tolls_amount + fare_amount ) AS fare_amount_810
FROM
taxirides.historical_taxi_rides_raw
WHERE
trip_distance > 1
AND fare_amount >= 3.0
AND pickup_longitude > -75
AND pickup_longitude < -73
AND dropoff_longitude > -75
AND dropoff_longitude < -73
AND pickup_latitude > 40
AND pickup_latitude < 42
AND dropoff_latitude > 40
AND dropoff_latitude < 42
AND passenger_count > 1
AND RAND() < 999999 / 1031673361

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?