我希望将此信息视为 python 消息:
但目前,我只能看到第一/第二
这是我目前使用的
from google.api_core.exceptions import BadRequest
if __name__ == '__main__':
try:
upload('XXX','XXX')
except BadRequest as e:
print('ERROR: {}'.format(str(e)))
Run Code Online (Sandbox Code Playgroud)
上传:
def upload(FILE_NAME, TABLE_ID):
client = bigquery.Client()
dataset_ref = client.dataset(config.DATASET_ID )
table_ref = dataset_ref.table(TABLE_ID)
job_config = bigquery.LoadJobConfig()
job_config.source_format = bigquery.SourceFormat.NEWLINE_DELIMITED_JSON
job_config.autodetect = False
with open(FILE_NAME, 'rb') as source_file:
job = client.load_table_from_file(
source_file,
table_ref,
location='EU', # Must match the destination dataset location.
job_config=job_config) # API request
job.result() # Waits for table load to complete.
Run Code Online (Sandbox Code Playgroud) python error-handling google-bigquery google-cloud-stackdriver python-bigquery
我正在尝试使用ExceptBigquery 中的现有子句。请在下面找到我的查询
select * EXCEPT (b.hosp_id, b.person_id,c.hosp_id) from
person a
inner join hospital b
on a.hosp_id= b.hosp_id
inner join reading c
on a.hosp_id= c.hosp_id
Run Code Online (Sandbox Code Playgroud)
如您所见,我使用了 3 个表。所有 3 个表都有hosp_id列,所以我想删除重复的列,即b.hosp_id和c.hosp_id。同样,我也想删除b.person_id列。
当我执行上述查询时,出现如下所示的语法错误
Syntax error: Expected ")" or "," but got "." at [9:19]
Run Code Online (Sandbox Code Playgroud)
请注意,我在 inExcept子句中使用的所有列都存在于所使用的表中。附加信息是所有使用的表都是使用with子句创建的临时表。当我通过选择感兴趣的列手动执行相同操作时,它工作正常。但是我有几列,无法手动执行此操作。
你能帮我吗?我正在尝试学习 Bigquery。您的意见会有所帮助