google-bigquery

How to get names of scheduled queries in bigquery

How to get names of scheduled queries in bigquery Question: Using a python client to connect with bigquery, how can we get names of all the scheduled queries present in that project? I tried following up with this link – https://cloud.google.com/bigquery/docs/reference/datatransfer/libraries But got no information on the names of the scheduled queries. Asked By: Runtime …

Total answers: 1

How to set default value for column in Google bigquery table using API from pyhton script

How to set default value for column in Google bigquery table using API from pyhton script Question: Class that crate column and describe it doesn’t have "default_value_expression" in the constructor. path: google/cloud/bigquery/schema.py class SchemaField: def __init__( name: str, field_type: str, mode: Any = "NULLABLE", description: Any = None, fields: Any = (), policy_tags: Any = …

Total answers: 1

How to parse user_defined_macro in regular function or PythonOperator in Airflow

How to parse user_defined_macro in regular function or PythonOperator in Airflow Question: We use managed Airflow inside a GCP project. When I used BigQueryInsertJobOperator to execute queries in a query file, it used to automatically replace user_defined_macros in those files with the set value. from airflow import DAG from datetime import datetime from airflow.providers.google.cloud.operators.bigquery import …

Total answers: 2

How to find out the type of partitioning in a table in google bigquery using python apis

How to find out the type of partitioning in a table in google bigquery using python apis Question: def partition(dataset1, dataset2): try: client.get_dataset(dataset2) print("Dataset {} already exists".format(dataset2)) except NotFound: print("Dataset {} not found".format(dataset2)) createDataset(dataset2) table = client.get_table(dataset1) # get the source dataset partition_column = table.time_partitioning.field #get the column name I tried using get_table description but …

Total answers: 1

Big query not converting the time but just changing the time zone

Big query not converting the time but just changing the time zone Question: Step # 1 — In my big query table, I created (in SQL) and saved a field (create_time) in Pacific time (America/Los_Angeles) and it appears like this -> 2022-05-31T06:07:46.044000 . update: This create time field is created from a UTC time field …

Total answers: 1

How to load a BigQuery table from a file in GCS Bucket using Airflow?

How to load a BigQuery table from a file in GCS Bucket using Airflow? Question: I am new to Airflow, and I am wondering, how do I load a file from a GCS Bucket to BigQuery? So far, I have managed to do BigQuery to GCS Bucket: bq_recent_questions_query = bigquery_operator.BigQueryOperator( task_id=’bq_recent_questions_query’, sql=""" SELECT owner_display_name, title, …

Total answers: 2

Bigquery dataset using pub/sub subscription

Bigquery dataset using pub/sub subscription Question: Trying to create a dataset using pub/sub subscription message. https://cloud.google.com/pubsub/docs/bigquery. This one provides how to write message to the table, but how can I create a dataset using the message. For example – if I have this is test1 in my subscription, then I should be able to take …

Total answers: 1

How to use f strings in BigQuery results variable in Python?

How to use f strings in BigQuery results variable in Python? Question: I am trying to create a script that iterates through a list, and runs sql queries using the list values as part of the WHERE condition. The SQL service in question is GBQ, and I am running the scripting process through python. I …

Total answers: 1

Google BigQuery Batch Query – job state is not updating after the job finished

Google BigQuery Batch Query – job state is not updating after the job finished Question: I run a google BigQuery batch query in a python script in jupyter notebook. Usually, the query takes about an hour when running in interactive mode. Today in the morning I checked and the script still displays the job is …

Total answers: 2

passing external date variable to a query python

passing external date variable to a query python Question: desired_date = "2022-09-28" #@param {type:"date"} import pandas as pd df = pd.io.gbq.read_gbq(”’ SELECT * FROM `gdelt-bq.gdeltv2.geg_gcnlapi` WHERE DATE(date) = desired_date LIMIT 1000 ”’, project_id=project_id, dialect=’standard’) Trying to pass desired_date to the SQL query, but everything I seem to do results in the following error: Reason: 400 …

Total answers: 2