GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Query error when trying to insert in partitioned table · Issue #4073 · googleapis/google-cloud-python

Query error when trying to insert in partitioned table #4073

New issue
Copy link
New issue
Copy link
Closed
Closed
Query error when trying to insert in partitioned table#4073
Copy link
Assignees
Kayrnt
Labels
api: bigqueryIssues related to the BigQuery API.

Description

@Kayrnt
Kayrnt
opened on Sep 27, 2017
Issue body actions

Using following code to write in an existing daily partitioned table:

bigquery_client = bigquery.Client(project=self.project_id)
dataset = bigquery_client.dataset(self.destination_dataset)
destination_table_with_day = "table$20170927"
sql = """
        #standardSQL
        ...
       """

table = dataset.table(destination_table_with_day)
table.partitioning_type = "DAY"
query = client.run_async_query(str(uuid.uuid4()), sql)
query.destination = table
query.write_disposition = 'WRITE_TRUNCATE'
query.begin()
query.result()

I expected similar result as the CLI with
bq query --use_legacy_sql=false --replace --destination_table 'dataset.table$20170927' "..." which works flawlessly

But it returned ERROR - 400 Partitioning specification must be provided in order to create partitioned table

I suspect that some parameters are missing that would result in this error such as https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query.timePartitioning.type

I'm not really that fluent in Python so I couldn't find out that it's the problem is the way I use the SDK or in the SDK.

I didn't find any sample related on that case inside https://github.com/GoogleCloudPlatform/python-docs-samples but I saw #2729 that could be related somehow.

Activity

  1. Kayrnt
    changed the title [-]Query error when inserted in partitioned table[/-] [+]Query error when trying to insert in partitioned table[/+] on Sep 27, 2017
  2. dhermes
    added
    api: bigqueryIssues related to the BigQuery API.
    on Sep 27, 2017
  3. Kayrnt commented on Sep 27, 2017

    @Kayrnt
    Kayrnt
    on Sep 27, 2017
    Author
    More actions

    I found out switching to the CLI implementation that the issue was that the table didn't existed (I was passing another dataset, not the one where I created the partitioned table).

    I guess the server error is pretty misleading as partitioned tables can't be created out of the format of the table name (ie table$YYYYMMdd or table$YYYYMMddHH for upcoming hour level support) and therefore requires a prior bq mk --time_partitioning_type=DAY dataset.table command to be run.

    After fixing my code, it looks like everything is working as intended.
    Sorry for the noise.

  4. Kayrnt
    closed this as completedon Sep 27, 2017
  5. JustinBeckwith
    assigned
    Kayrnt
    on Feb 1, 2021
  6. parthea
    added a commit that references this issue on Jul 6, 2023

    chore(deps): update dependency google-auth to v1.17.1 [(#4073)](Googl…

    25ea648
  7. parthea
    added a commit that references this issue on Sep 22, 2023

    chore: move samples from python-docs-sample (#66)

    d3dcbbc
  8. parthea
    added a commit that references this issue on Oct 21, 2023

    move monitoring samples from python-docs-samples (#51)

    d95f563
  9. parthea
    added a commit that references this issue on Aug 21, 2025

    chore(deps): update dependency google-auth to v1.17.1 [(#4073)](Googl…

    ac56a24
  10. parthea
    added a commit that references this issue on Sep 16, 2025

    chore(deps): update dependency google-auth to v1.17.1 [(#4073)](Googl…

    4d708c4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @Kayrnt
    Kayrnt

Labels

api: bigqueryIssues related to the BigQuery API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.