From 0707012832fdb6995e99563b12815c7de4d88fb7 Mon Sep 17 00:00:00 2001 From: Nicholas Large <84149918+nlarge-google@users.noreply.github.com> Date: Wed, 13 Oct 2021 10:04:37 -0500 Subject: [PATCH] feat: Onboard San Francisco Bikeshare Stations (#191) --- .../_images/run_csv_transform_kub/Dockerfile | 38 ++++ .../run_csv_transform_kub/csv_transform.py | 215 ++++++++++++++++++ .../run_csv_transform_kub/requirements.txt | 3 + .../_terraform/bikeshare_stations_pipeline.tf | 39 ++++ .../_terraform/provider.tf | 28 +++ ...an_francisco_bikeshare_stations_dataset.tf | 26 +++ .../_terraform/variables.tf | 23 ++ .../bikeshare_stations_dag.py | 159 +++++++++++++ .../bikeshare_stations/pipeline.yaml | 130 +++++++++++ .../dataset.yaml | 27 +++ 10 files changed, 688 insertions(+) create mode 100644 datasets/san_francisco_bikeshare_stations/_images/run_csv_transform_kub/Dockerfile create mode 100644 datasets/san_francisco_bikeshare_stations/_images/run_csv_transform_kub/csv_transform.py create mode 100644 datasets/san_francisco_bikeshare_stations/_images/run_csv_transform_kub/requirements.txt create mode 100644 datasets/san_francisco_bikeshare_stations/_terraform/bikeshare_stations_pipeline.tf create mode 100644 datasets/san_francisco_bikeshare_stations/_terraform/provider.tf create mode 100644 datasets/san_francisco_bikeshare_stations/_terraform/san_francisco_bikeshare_stations_dataset.tf create mode 100644 datasets/san_francisco_bikeshare_stations/_terraform/variables.tf create mode 100644 datasets/san_francisco_bikeshare_stations/bikeshare_stations/bikeshare_stations_dag.py create mode 100644 datasets/san_francisco_bikeshare_stations/bikeshare_stations/pipeline.yaml create mode 100644 datasets/san_francisco_bikeshare_stations/dataset.yaml diff --git a/datasets/san_francisco_bikeshare_stations/_images/run_csv_transform_kub/Dockerfile b/datasets/san_francisco_bikeshare_stations/_images/run_csv_transform_kub/Dockerfile new file mode 100644 index 000000000..85af90570 --- /dev/null +++ b/datasets/san_francisco_bikeshare_stations/_images/run_csv_transform_kub/Dockerfile @@ -0,0 +1,38 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# The base image for this build +# FROM gcr.io/google.com/cloudsdktool/cloud-sdk:slim +FROM python:3.8 + +# Allow statements and log messages to appear in Cloud logs +ENV PYTHONUNBUFFERED True + +# Copy the requirements file into the image +COPY requirements.txt ./ + +# Install the packages specified in the requirements file +RUN python3 -m pip install --no-cache-dir -r requirements.txt + +# The WORKDIR instruction sets the working directory for any RUN, CMD, +# ENTRYPOINT, COPY and ADD instructions that follow it in the Dockerfile. +# If the WORKDIR doesn’t exist, it will be created even if it’s not used in +# any subsequent Dockerfile instruction +WORKDIR /custom + +# Copy the specific data processing script/s in the image under /custom/* +COPY ./csv_transform.py . + +# Command to run the data processing script when the container is run +CMD ["python3", "csv_transform.py"] diff --git a/datasets/san_francisco_bikeshare_stations/_images/run_csv_transform_kub/csv_transform.py b/datasets/san_francisco_bikeshare_stations/_images/run_csv_transform_kub/csv_transform.py new file mode 100644 index 000000000..28589d92c --- /dev/null +++ b/datasets/san_francisco_bikeshare_stations/_images/run_csv_transform_kub/csv_transform.py @@ -0,0 +1,215 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import json +import logging +import os +import pathlib + +import pandas as pd +import requests +from google.cloud import storage + + +def main( + source_url_json: str, + source_file: pathlib.Path, + target_file: pathlib.Path, + chunksize: str, + target_gcs_bucket: str, + target_gcs_path: str, +) -> None: + + logging.info("San Francisco Bikeshare Stations process started") + + pathlib.Path("./files").mkdir(parents=True, exist_ok=True) + source_file_stations_json = str(source_file).replace(".csv", "") + "_stations.json" + download_file_json(source_url_json, source_file_stations_json, source_file) + + chunksz = int(chunksize) + + logging.info(f"Opening batch file {source_file}") + with pd.read_csv( + source_file, # path to main source file to load in batches + engine="python", + encoding="utf-8", + quotechar='"', # string separator, typically double-quotes + chunksize=chunksz, # size of batch data, in no. of records + sep=",", # data column separator, typically "," + ) as reader: + for chunk_number, chunk in enumerate(reader): + target_file_batch = str(target_file).replace( + ".csv", "-" + str(chunk_number) + ".csv" + ) + df = pd.DataFrame() + df = pd.concat([df, chunk]) + process_chunk(df, target_file_batch, target_file, (not chunk_number == 0)) + + upload_file_to_gcs(target_file, target_gcs_bucket, target_gcs_path) + + logging.info("San Francisco Bikeshare Stations process completed") + + +def process_chunk( + df: pd.DataFrame, target_file_batch: str, target_file: str, skip_header: bool +) -> None: + df = rename_headers(df) + df = filter_empty_data(df) + df = generate_location(df) + df = resolve_datatypes(df) + df = reorder_headers(df) + save_to_new_file(df, file_path=str(target_file_batch)) + append_batch_file(target_file_batch, target_file, skip_header, not (skip_header)) + + +def rename_headers(df: pd.DataFrame) -> None: + logging.info("Renaming Headers") + header_names = { + "data.stations.station_id": "station_id", + "data.stations.name": "name", + "data.stations.short_name": "short_name", + "data.stations.lat": "lat", + "data.stations.lon": "lon", + "data.stations.region_id": "region_id", + "data.stations.rental_methods": "rental_methods", + "data.stations.capacity": "capacity", + "data.stations.eightd_has_key_dispenser": "eightd_has_key_dispenser", + "data.stations.has_kiosk": "has_kiosk", + "data.stations.external_id": "external_id", + } + + df.rename(columns=header_names) + + return df + + +def filter_empty_data(df: pd.DataFrame) -> pd.DataFrame: + logging.info("Filter rows with empty key data") + df = df[df["station_id"] != ""] + df = df[df["name"] != ""] + df = df[df["lat"] != ""] + df = df[df["lon"] != ""] + + return df + + +def generate_location(df: pd.DataFrame) -> pd.DataFrame: + logging.info("Generating location data") + df["station_geom"] = ( + "POINT(" + + df["lon"][:].astype("string") + + " " + + df["lat"][:].astype("string") + + ")" + ) + + return df + + +def resolve_datatypes(df: pd.DataFrame) -> pd.DataFrame: + logging.info("Resolving datatypes") + df["region_id"] = df["region_id"].astype("Int64") + + return df + + +def reorder_headers(df: pd.DataFrame) -> pd.DataFrame: + logging.info("Reordering Headers") + df = df[ + [ + "station_id", + "name", + "short_name", + "lat", + "lon", + "region_id", + "rental_methods", + "capacity", + "external_id", + "eightd_has_key_dispenser", + "has_kiosk", + "station_geom", + ] + ] + + return df + + +def append_batch_file( + batch_file_path: str, target_file_path: str, skip_header: bool, truncate_file: bool +) -> None: + data_file = open(batch_file_path, "r") + if truncate_file: + target_file = open(target_file_path, "w+").close() + target_file = open(target_file_path, "a+") + if skip_header: + logging.info( + f"Appending batch file {batch_file_path} to {target_file_path} with skip header" + ) + next(data_file) + else: + logging.info(f"Appending batch file {batch_file_path} to {target_file_path}") + target_file.write(data_file.read()) + data_file.close() + target_file.close() + if os.path.exists(batch_file_path): + os.remove(batch_file_path) + + +def save_to_new_file(df, file_path) -> None: + df.to_csv(file_path, index=False) + + +def download_file_json( + source_url_json: str, source_file_json: str, source_file_csv: str +) -> None: + + # this function extracts the json from a source url and creates + # a csv file from that data to be used as an input file + logging.info(f"Downloading stations json file {source_url_json}") + + # download json url into object r + r = requests.get(source_url_json + ".json", stream=True) + + # push object r (json) into json file + with open(source_file_json, "wb") as f: + for chunk in r: + f.write(chunk) + + f = open( + source_file_json.strip(), + ) + json_data = json.load(f) + df = pd.DataFrame(json_data["data"]["stations"]) + df.to_csv(source_file_csv, index=False) + + +def upload_file_to_gcs(file_path: pathlib.Path, gcs_bucket: str, gcs_path: str) -> None: + storage_client = storage.Client() + bucket = storage_client.bucket(gcs_bucket) + blob = bucket.blob(gcs_path) + blob.upload_from_filename(file_path) + + +if __name__ == "__main__": + logging.getLogger().setLevel(logging.INFO) + + main( + source_url_json=os.environ["SOURCE_URL_JSON"], + source_file=pathlib.Path(os.environ["SOURCE_FILE"]).expanduser(), + target_file=pathlib.Path(os.environ["TARGET_FILE"]).expanduser(), + chunksize=os.environ["CHUNKSIZE"], + target_gcs_bucket=os.environ["TARGET_GCS_BUCKET"], + target_gcs_path=os.environ["TARGET_GCS_PATH"], + ) diff --git a/datasets/san_francisco_bikeshare_stations/_images/run_csv_transform_kub/requirements.txt b/datasets/san_francisco_bikeshare_stations/_images/run_csv_transform_kub/requirements.txt new file mode 100644 index 000000000..f36704793 --- /dev/null +++ b/datasets/san_francisco_bikeshare_stations/_images/run_csv_transform_kub/requirements.txt @@ -0,0 +1,3 @@ +requests +pandas +google-cloud-storage diff --git a/datasets/san_francisco_bikeshare_stations/_terraform/bikeshare_stations_pipeline.tf b/datasets/san_francisco_bikeshare_stations/_terraform/bikeshare_stations_pipeline.tf new file mode 100644 index 000000000..7935b5868 --- /dev/null +++ b/datasets/san_francisco_bikeshare_stations/_terraform/bikeshare_stations_pipeline.tf @@ -0,0 +1,39 @@ +/** + * Copyright 2021 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +resource "google_bigquery_table" "bikeshare_stations" { + project = var.project_id + dataset_id = "san_francisco_bikeshare_stations" + table_id = "bikeshare_stations" + + description = "san francisco bikeshare stations" + + + + + depends_on = [ + google_bigquery_dataset.san_francisco_bikeshare_stations + ] +} + +output "bigquery_table-bikeshare_stations-table_id" { + value = google_bigquery_table.bikeshare_stations.table_id +} + +output "bigquery_table-bikeshare_stations-id" { + value = google_bigquery_table.bikeshare_stations.id +} diff --git a/datasets/san_francisco_bikeshare_stations/_terraform/provider.tf b/datasets/san_francisco_bikeshare_stations/_terraform/provider.tf new file mode 100644 index 000000000..23ab87dcd --- /dev/null +++ b/datasets/san_francisco_bikeshare_stations/_terraform/provider.tf @@ -0,0 +1,28 @@ +/** + * Copyright 2021 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +provider "google" { + project = var.project_id + impersonate_service_account = var.impersonating_acct + region = var.region +} + +data "google_client_openid_userinfo" "me" {} + +output "impersonating-account" { + value = data.google_client_openid_userinfo.me.email +} diff --git a/datasets/san_francisco_bikeshare_stations/_terraform/san_francisco_bikeshare_stations_dataset.tf b/datasets/san_francisco_bikeshare_stations/_terraform/san_francisco_bikeshare_stations_dataset.tf new file mode 100644 index 000000000..1c41bc746 --- /dev/null +++ b/datasets/san_francisco_bikeshare_stations/_terraform/san_francisco_bikeshare_stations_dataset.tf @@ -0,0 +1,26 @@ +/** + * Copyright 2021 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +resource "google_bigquery_dataset" "san_francisco_bikeshare_stations" { + dataset_id = "san_francisco_bikeshare_stations" + project = var.project_id + description = "san_francisco_bikeshare_stations" +} + +output "bigquery_dataset-san_francisco_bikeshare_stations-dataset_id" { + value = google_bigquery_dataset.san_francisco_bikeshare_stations.dataset_id +} diff --git a/datasets/san_francisco_bikeshare_stations/_terraform/variables.tf b/datasets/san_francisco_bikeshare_stations/_terraform/variables.tf new file mode 100644 index 000000000..c3ec7c506 --- /dev/null +++ b/datasets/san_francisco_bikeshare_stations/_terraform/variables.tf @@ -0,0 +1,23 @@ +/** + * Copyright 2021 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +variable "project_id" {} +variable "bucket_name_prefix" {} +variable "impersonating_acct" {} +variable "region" {} +variable "env" {} + diff --git a/datasets/san_francisco_bikeshare_stations/bikeshare_stations/bikeshare_stations_dag.py b/datasets/san_francisco_bikeshare_stations/bikeshare_stations/bikeshare_stations_dag.py new file mode 100644 index 000000000..e041ca4d5 --- /dev/null +++ b/datasets/san_francisco_bikeshare_stations/bikeshare_stations/bikeshare_stations_dag.py @@ -0,0 +1,159 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +from airflow import DAG +from airflow.providers.cncf.kubernetes.operators import kubernetes_pod +from airflow.providers.google.cloud.transfers import gcs_to_bigquery + +default_args = { + "owner": "Google", + "depends_on_past": False, + "start_date": "2021-03-01", +} + + +with DAG( + dag_id="san_francisco_bikeshare_stations.bikeshare_stations", + default_args=default_args, + max_active_runs=1, + schedule_interval="@daily", + catchup=False, + default_view="graph", +) as dag: + + # Run CSV transform within kubernetes pod + transform_csv = kubernetes_pod.KubernetesPodOperator( + task_id="transform_csv", + name="bikeshare_stations", + namespace="default", + affinity={ + "nodeAffinity": { + "requiredDuringSchedulingIgnoredDuringExecution": { + "nodeSelectorTerms": [ + { + "matchExpressions": [ + { + "key": "cloud.google.com/gke-nodepool", + "operator": "In", + "values": ["pool-e2-standard-4"], + } + ] + } + ] + } + } + }, + image_pull_policy="Always", + image="{{ var.json.san_francisco_bikeshare_stations.container_registry.run_csv_transform_kub }}", + env_vars={ + "SOURCE_URL_JSON": "https://gbfs.baywheels.com/gbfs/fr/station_information", + "SOURCE_FILE": "files/data.csv", + "TARGET_FILE": "files/data_output.csv", + "CHUNKSIZE": "750000", + "TARGET_GCS_BUCKET": "{{ var.value.composer_bucket }}", + "TARGET_GCS_PATH": "data/san_francisco_bikeshare_stations/bikeshare_stations/data_output.csv", + }, + resources={"limit_memory": "8G", "limit_cpu": "3"}, + ) + + # Task to load CSV data to a BigQuery table + load_to_bq = gcs_to_bigquery.GCSToBigQueryOperator( + task_id="load_to_bq", + bucket="{{ var.value.composer_bucket }}", + source_objects=[ + "data/san_francisco_bikeshare_stations/bikeshare_stations/data_output.csv" + ], + source_format="CSV", + destination_project_dataset_table="san_francisco.bikeshare_station_info", + skip_leading_rows=1, + allow_quoted_newlines=True, + write_disposition="WRITE_TRUNCATE", + schema_fields=[ + { + "name": "station_id", + "type": "INTEGER", + "description": "Unique identifier of a station.", + "mode": "REQUIRED", + }, + { + "name": "name", + "type": "STRING", + "description": "Public name of the station", + "mode": "REQUIRED", + }, + { + "name": "short_name", + "type": "STRING", + "description": "Short name or other type of identifier, as used by the data publisher", + "mode": "NULLABLE", + }, + { + "name": "lat", + "type": "FLOAT", + "description": "The latitude of station. The field value must be a valid WGS 84 latitude in decimal degrees format. See: http://en.wikipedia.org/wiki/World_Geodetic_System, https://en.wikipedia.org/wiki/Decimal_degrees", + "mode": "REQUIRED", + }, + { + "name": "lon", + "type": "FLOAT", + "description": "The longitude of station. The field value must be a valid WGS 84 longitude in decimal degrees format. See: http://en.wikipedia.org/wiki/World_Geodetic_System, https://en.wikipedia.org/wiki/Decimal_degrees", + "mode": "REQUIRED", + }, + { + "name": "region_id", + "type": "INTEGER", + "description": "ID of the region where station is located", + "mode": "NULLABLE", + }, + { + "name": "rental_methods", + "type": "STRING", + "description": "Array of enumerables containing the payment methods accepted at this station. Current valid values (in CAPS) are: KEY (i.e. operator issued bike key / fob / card) CREDITCARD PAYPASS APPLEPAY ANDROIDPAY TRANSITCARD ACCOUNTNUMBER PHONE This list is intended to be as comprehensive at the time of publication as possible but is subject to change, as defined in File Requirements above", + "mode": "NULLABLE", + }, + { + "name": "capacity", + "type": "INTEGER", + "description": "Number of total docking points installed at this station, both available and unavailable", + "mode": "NULLABLE", + }, + { + "name": "external_id", + "type": "STRING", + "description": "", + "mode": "NULLABLE", + }, + { + "name": "eightd_has_key_dispenser", + "type": "BOOLEAN", + "description": "", + "mode": "NULLABLE", + }, + { + "name": "has_kiosk", + "type": "BOOLEAN", + "description": "", + "mode": "NULLABLE", + }, + { + "name": "station_geom", + "type": "GEOGRAPHY", + "description": "", + "mode": "NULLABLE", + }, + ], + ) + + transform_csv >> load_to_bq diff --git a/datasets/san_francisco_bikeshare_stations/bikeshare_stations/pipeline.yaml b/datasets/san_francisco_bikeshare_stations/bikeshare_stations/pipeline.yaml new file mode 100644 index 000000000..37ee16150 --- /dev/null +++ b/datasets/san_francisco_bikeshare_stations/bikeshare_stations/pipeline.yaml @@ -0,0 +1,130 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +--- +resources: + + - type: bigquery_table + table_id: "bikeshare_stations" + description: "san francisco bikeshare stations" + +dag: + airflow_version: 2 + initialize: + dag_id: bikeshare_stations + default_args: + owner: "Google" + depends_on_past: False + start_date: '2021-03-01' + max_active_runs: 1 + schedule_interval: "@daily" # run once a week at Sunday 12am + catchup: False + default_view: graph + + tasks: + + - operator: "KubernetesPodOperator" + description: "Run CSV transform within kubernetes pod" + + args: + + task_id: "transform_csv" + name: "bikeshare_stations" + namespace: "default" + affinity: + nodeAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + nodeSelectorTerms: + - matchExpressions: + - key: cloud.google.com/gke-nodepool + operator: In + values: + - "pool-e2-standard-4" + image_pull_policy: "Always" + image: "{{ var.json.san_francisco_bikeshare_stations.container_registry.run_csv_transform_kub }}" + env_vars: + SOURCE_URL_JSON: "https://gbfs.baywheels.com/gbfs/fr/station_information" + SOURCE_FILE: "files/data.csv" + TARGET_FILE: "files/data_output.csv" + CHUNKSIZE: "750000" + TARGET_GCS_BUCKET: "{{ var.value.composer_bucket }}" + TARGET_GCS_PATH: "data/san_francisco_bikeshare_stations/bikeshare_stations/data_output.csv" + resources: + limit_memory: "8G" + limit_cpu: "3" + + - operator: "GoogleCloudStorageToBigQueryOperator" + description: "Task to load CSV data to a BigQuery table" + + args: + task_id: "load_to_bq" + bucket: "{{ var.value.composer_bucket }}" + source_objects: ["data/san_francisco_bikeshare_stations/bikeshare_stations/data_output.csv"] + source_format: "CSV" + destination_project_dataset_table: "san_francisco.bikeshare_station_info" + skip_leading_rows: 1 + allow_quoted_newlines: True + write_disposition: "WRITE_TRUNCATE" + schema_fields: + - name: "station_id" + type: "INTEGER" + description: "Unique identifier of a station." + mode: "REQUIRED" + - name: "name" + type: "STRING" + description: "Public name of the station" + mode: "REQUIRED" + - name: "short_name" + type: "STRING" + description: "Short name or other type of identifier, as used by the data publisher" + mode: "NULLABLE" + - name: "lat" + type: "FLOAT" + description: "The latitude of station. The field value must be a valid WGS 84 latitude in decimal degrees format. See: http://en.wikipedia.org/wiki/World_Geodetic_System, https://en.wikipedia.org/wiki/Decimal_degrees" + mode: "REQUIRED" + - name: "lon" + type: "FLOAT" + description: "The longitude of station. The field value must be a valid WGS 84 longitude in decimal degrees format. See: http://en.wikipedia.org/wiki/World_Geodetic_System, https://en.wikipedia.org/wiki/Decimal_degrees" + mode: "REQUIRED" + - name: "region_id" + type: "INTEGER" + description: "ID of the region where station is located" + mode: "NULLABLE" + - name: "rental_methods" + type: "STRING" + description: "Array of enumerables containing the payment methods accepted at this station. Current valid values (in CAPS) are: KEY (i.e. operator issued bike key / fob / card) CREDITCARD PAYPASS APPLEPAY ANDROIDPAY TRANSITCARD ACCOUNTNUMBER PHONE This list is intended to be as comprehensive at the time of publication as possible but is subject to change, as defined in File Requirements above" + mode: "NULLABLE" + - name: "capacity" + type: "INTEGER" + description: "Number of total docking points installed at this station, both available and unavailable" + mode: "NULLABLE" + - name: "external_id" + type: "STRING" + description: "" + mode: "NULLABLE" + - name: "eightd_has_key_dispenser" + type: "BOOLEAN" + description: "" + mode: "NULLABLE" + - name: "has_kiosk" + type: "BOOLEAN" + description: "" + mode: "NULLABLE" + - name: "station_geom" + type: "GEOGRAPHY" + description: "" + mode: "NULLABLE" + + graph_paths: + - "transform_csv >> load_to_bq" diff --git a/datasets/san_francisco_bikeshare_stations/dataset.yaml b/datasets/san_francisco_bikeshare_stations/dataset.yaml new file mode 100644 index 000000000..5f1056234 --- /dev/null +++ b/datasets/san_francisco_bikeshare_stations/dataset.yaml @@ -0,0 +1,27 @@ +# Copyright 2021 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +dataset: + name: san_francisco_bikeshare_stations + friendly_name: ~ + description: ~ + dataset_sources: ~ + terms_of_use: ~ + + +resources: + + - type: bigquery_dataset + dataset_id: san_francisco_bikeshare_stations + description: san_francisco_bikeshare_stations