为了查看没有重复记录的记录,我使用这个 SQL
SELECT * EXCEPT(row_number)
FROM (SELECT*,ROW_NUMBER() OVER (PARTITION BY orderid) row_number
FROM `TABLE`)
WHERE row_number = 1
Run Code Online (Sandbox Code Playgroud)
仅显示单个表中的重复记录的最佳实践是什么?
我希望将此信息视为 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