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

Query Cost Estimation #19

Closed
Italosayan opened this issue Nov 30, 2023 · 2 comments
Closed

Query Cost Estimation #19

Italosayan opened this issue Nov 30, 2023 · 2 comments

Comments

@Italosayan
Copy link

I'm looking to make a contribution to the project.

@archiewood have you looked into adding the query cost estimation to the plugin?

image
from google.cloud import bigquery

# Construct a BigQuery client object.
client = bigquery.Client()

# Set your query here
query = """
SELECT name, count
FROM `table`
WHERE state = 'TX'
"""

# Set up the dry run query configuration
job_config = bigquery.QueryJobConfig(dry_run=True, use_query_cache=False)

# API request - dry run query
dry_run_query_job = client.query(query, job_config=job_config)

# A dry run query does not provide a row iterator, only statistics
print(f"This query will process {dry_run_query_job.total_bytes_processed} bytes.")
@archiewood
Copy link
Member

archiewood commented Nov 30, 2023

Hi @Italosayan

I've briefly looked into it, but not extensively. Contributions are certainly welcomed!

I think calling the dry run function shouldn't be too bad, similar to your example above.

I suspect the hard part is wiring it up into SQLtools, as it does not have inbuilt functionality to support cost estimation.

We need:

  • a way for the user to initiate the dry run
  • a way to expose the results of the dry run back to the user

Feel free to reach out on slack if I can help at all.

@archiewood
Copy link
Member

Also I think this is a duplicate of #13 - let's continue over there!

@archiewood archiewood closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants