Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bigquery: Temporary table support #5107

Closed
prochac opened this issue Nov 10, 2021 · 4 comments
Closed

bigquery: Temporary table support #5107

prochac opened this issue Nov 10, 2021 · 4 comments
Assignees
Labels
api: bigquery Issues related to the BigQuery API. type: question Request for information or clarification. Not an issue.

Comments

@prochac
Copy link

prochac commented Nov 10, 2021

BigQuery SDK should support temporary tables. The same temp table as it can be created by following query, if SQL method is used:

CREATE TEMPORARY TABLE foo ( ... )

https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_table_statement

But by SDK documentation we should create table with expiration time.
https://pkg.go.dev/cloud.google.com/go/bigquery#hdr-Datasets_and_Tables
That's the only part mentioning temporary tables.
But It is an old way to do it, since 2019, when CREATE TEMP TABLE was introduced.

I think it should be as a parameter for
https://pkg.go.dev/cloud.google.com/go/bigquery#Table.Create
, so part of
https://pkg.go.dev/cloud.google.com/go/bigquery#TableMetadata

Or am I missing something?

@prochac prochac added the triage me I really want to be triaged. label Nov 10, 2021
@product-auto-label product-auto-label bot added the api: bigquery Issues related to the BigQuery API. label Nov 10, 2021
@shollyman
Copy link
Contributor

I suppose it comes down to what you're doing with the temporary table. If you're just wanting to do multi-statement queries, it's perfectly reasonable to supply SQL text for execution that's effectively a CREATE TEMPORARY TABLE foo AS ....; SELECT blah FROM foo;

If you want to issue multiple queries over time and not in the same script block, what you'll want to do is bind the statements to a session. This capability was recently added via #4754.

If your use case falls outside those patterns, perhaps you could describe what your intent is in a bit more detail?

@shollyman shollyman added type: question Request for information or clarification. Not an issue. and removed triage me I really want to be triaged. labels Nov 11, 2021
@prochac
Copy link
Author

prochac commented Nov 11, 2021

We use temp table to run merge query to final table

MERGE the_table T USING temp_table S ON T.col = S.col WHEN NOT MATCHED THEN INSERT ...

Currently, we create a regular table for it.

@shollyman
Copy link
Contributor

I'm still not sure what you're requesting.

A temporary table is ephemeral, and exists either for the lifetime of a single query job (or a query session). It doesn't really make sense to create the temp table programmatically the same way you would a managed table by invoking table.Create() for example, as that's outside the scope of a query.

What are you envisioning that you would do with a temp table created via the the library rather than SQL?

@shollyman
Copy link
Contributor

Closing this, as there's been no further interaction. If you have more details, feel free to comment and we can reopen this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigquery Issues related to the BigQuery API. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants