Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

export to BigQuery with partition does not seem to work #177

Closed
jennylover opened this issue Apr 19, 2021 · 6 comments
Closed

export to BigQuery with partition does not seem to work #177

jennylover opened this issue Apr 19, 2021 · 6 comments
Labels
api: cloudasset Issues related to the googleapis/python-asset API. type: question Request for information or clarification. Not an issue.

Comments

@jennylover
Copy link

Hi,

When i tried to export asset data to the BigQuery, it is working fine. But, if I add partition option, created table does not seemed partitioned in BQ.

In the SDK, there are only 3 enums are available for partition_key, is there any way to get partition by DAY?

Thanks,

@product-auto-label product-auto-label bot added the api: cloudasset Issues related to the googleapis/python-asset API. label Apr 19, 2021
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Apr 19, 2021
@busunkim96 busunkim96 added type: question Request for information or clarification. Not an issue. and removed triage me I really want to be triaged. labels Apr 20, 2021
@busunkim96
Copy link
Contributor

@lvvvvvf I see you authored the export to BigQuery samples, could you take a look?

@lvvvvvf
Copy link
Contributor

lvvvvvf commented Apr 20, 2021

Add Ziqi who's the poc for partitioned table

@busunkim96
Copy link
Contributor

@Larittic-GG Could you take a look?

@Larittic-GG
Copy link
Contributor

Sorry for the late reply.

First, for "created table does not seemed partitioned in BQ", can you recheck what the table details page? The Table Type row should display "Partitioned".

Secondly, for every value of the partition key enum other than PARTITION_KEY_UNSPECIFIED, the table is actually partitioned by daily granularity. See details about BigQuery partitioned table in https://cloud.google.com/bigquery/docs/partitioned-tables.

Let me know if you have more questions. Thanks!

@kbroughton
Copy link

I found it a bit confusing that the partition key was bound inside the output_config. This code works for me

` if partition_key:
partition_spec = asset_v1.PartitionSpec()
partition_spec.partition_key = partition_key
output_config.bigquery_destination.partition_spec = partition_spec

try:
if partition_key:
output_config.bigquery_destination.table = '%s_resource' % (bq_table)
else:
output_config.bigquery_destination.table = '%s_resource_%s' % (bq_table, read_time.strftime('%Y%m%d'))
logging.info('output_config {} '.format(output_config))

  response = client.export_assets(
      request={
          'parent': parent,
          'read_time': read_time,
          'content_type': asset_v1.ContentType.RESOURCE,
          'output_config': output_config
      }
  )

`

@parthea
Copy link
Contributor

parthea commented Feb 5, 2022

I'm going to close this issue due to inactivity. Please feel free to re-open it if you have additional questions.

@parthea parthea closed this as completed Feb 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: cloudasset Issues related to the googleapis/python-asset API. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

7 participants