Comments (4)
I'm not sure if I like this over the current design. For example, with query
, it's perfectly reasonable to set timeout=0
. This simply means the query is submitted and the results will be fetched at some point in the future. It wouldn't make sense to force people to catch an exception there. I think the current design encourages people to think asynchronously, which they should.
That's not to say the API can't be improved. Maybe using futures would make more sense?
job_id, results_future = client.query('SELECT * FROM dataset.my_table LIMIT 1000')
try:
results_future.result(timeout=5)
except TimeoutException:
print "Timeout"
Just something to think about.
from bigquery-python.
How about setting query
timeout default value to 0 so that it will run asynchronously by default or when the user wants to?
My suggestions was because there isn't a straightforward way to know if a query is returning empty list due to timeout or due to empty result.
If users wants to run asynchronously, they can still use
job_id, _results = client.query('SELECT * FROM dataset.my_table LIMIT 1000')
# Do other stuffs
complete, row_count = client.check_job(job_id)
if not complete:
print "Timeout
If they want to run in synchronous manner with timeout, they can use
try:
job_id, results = client.query('SELECT * FROM dataset.my_table LIMIT 1000', timeout=5)
except BigQueryTimeoutException:
print "Timeout"
Futures is another possible way but I'm biased here and I prefer the appoarch above =). For my use case, I need to run queries in a synchronous way with timeouts since the second query depends on the first query. Async would still work here, though not as clean as I wanted it to be.
from bigquery-python.
Yes, I like the synchronous approach you describe and defaulting to async. That makes sense to me.
from bigquery-python.
Great, I'll follow up with a PR
from bigquery-python.
Related Issues (20)
- ImportError: cannot import name get_client HOT 6
- Queries results limited HOT 1
- get statistics of the job HOT 1
- specifying dataset location when using create_dataset method HOT 2
- create_table() documentation incorrect HOT 1
- Table expiration time should be a long HOT 1
- Functionality to upload/download file from local to gcs and vice versa
- not working anymore due to KeyError: 'google'
- Get Client with API key
- documentation typo "destination_urls" HOT 1
- bigquery.errors.JobInsertException: Reason:invalid. Message:Table wasel-95b26:com_mysada_news_ANDROID.app_events_20170611 cannot be exported as CSV because it has a nested schema. HOT 1
- get_query_rows offset option fails across pages
- Few typos in documentation HOT 1
- Cannot import get_client
- ImportError: No module named bigquery
- Not getting the full list of datasets when there are more than 50 datasets in the project HOT 1
- Standard SQL support HOT 3
- "Please look into the error stream for more details." HOT 5
- Request had insufficient authentication scopes when creating a table HOT 6
- Is this project still ongoing?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bigquery-python.