Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

JINIers

220609_Loading data into BigQuery 본문

GCP/Qwiklabs

220609_Loading data into BigQuery

JINIers 2022. 6. 9. 09:05

BigQuery에 데이터 로드하기

 

BigQuery : google의 완전관리형, NoOps, 저비용분석 데이터베이스

[학습내용]

1. 다양한 소스에서 BigQuery에 데이터 로드하기

2. CLI 및 콘솔을 사용하여 BigQuery에 데이터 로드하기

3. DDL을 사용하여 테이블 만들기


1. 테이블을 저장하기 위해 새 데이터세트 만들기


bigquery > create dataset > name : nyctaxi > create


2. CSV에서 새 데이터세트 수집

 

create table > create

  • Create table from: Upload
  • Choose File: select the file you downloaded locally earlier
  • File format: CSV
  • name : 2018trips

[올해 가장 비싼 여행 상위 5개 나열]

#standardSQL
SELECT
  *
FROM
  nyctaxi.2018trips
ORDER BY
  fare_amount DESC
LIMIT  5

 


3. google cloud storage에서 새 데이터세트 수집하기

* cloud shell에 하기

 

[빅쿼리 데이터에 하위집합 로드]

bq load \
--source_format=CSV \
--autodetect \
--noreplace  \
nyctaxi.2018trips \
gs://cloud-training/OCBL013/nyc_tlc_yellow_trips_2018_subset_2.csv

작업 완료되면 테이블 세부정보 확인


4. DDL이 있는 다른 테이블에서 테이블 만들기

 


[1월 여행의 픽업날짜와 시간 추출]

#standardSQL
CREATE TABLE
  nyctaxi.january_trips AS
SELECT
  *
FROM
  nyctaxi.2018trips
WHERE
  EXTRACT(Month
  FROM
    pickup_datetime)=1;

 


[1월 여행 중 가장 긴 이동거리]

#standardSQL
SELECT
  *
FROM
  nyctaxi.january_trips
ORDER BY
  trip_distance DESC
LIMIT
  1

 

Comments