Reputation: 2642
Within a datalab notebook it's possible to export BiqQuery results directly into a dataframe. I have an example that works for legacy SQL and I need to adjust to make it work for standard SQL. I can't find a syntax that works for this. Here's what I think I need to write:
import datalab.bigquery as bq
import pandas as pd
%%sql --module data_name -d standard
SELECT COUNT(*) AS count FROM `project.dataset.ga_sessions_*` WHERE _TABLE_SUFFIX BETWEEN '20170126' AND '20170126'
my_data_frame = bq.Query(data_name).to_dataframe()
Something must be wrong with this syntax as I get the error:
Exception: invalid: Invalid table name: `project.dataset.table.ga_sessions_*`
How can I fix this to work for Standard SQL?
Upvotes: 2
Views: 1587
Reputation: 729
Note that this %%sql magic has been supplanted by the %%bq magic, and standard sql is now the default:
Upvotes: 0
Reputation: 11777
Maybe you need to make it explicit that you want to use Standard SQL in datalab.
Let us know if this works for you (make sure your branch is up-to-date with the master branch):
my_data_frame = bq.Query(data_name).to_dataframe(dialect='standard')
Upvotes: 5