This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BigQueryClient(object): | |
def __init__(self, project_id): | |
self.project_id = project_id | |
def _get_conf(self, bucket, dataset_id, table_id): | |
return { | |
"fs.gs.project.id": self.project_id, | |
"mapred.bq.project.id": self.project_id, # default project | |
"mapred.bq.gcs.bucket": bucket, # gcs bucket holding the temperory path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from pyspark.sql.types import * | |
# Define the schema | |
schema = StructType( | |
[StructField("name", StringType(), True), StructField("age", IntegerType(), True)] | |
) | |
# Write the schema | |
with open("schema.json", "w") as f: |