LoginSignup
4
1

More than 5 years have passed since last update.

Google DatalabからBigQueryへ標準SQLを投げたい

Last updated at Posted at 2017-06-06

Google Datalab から標準SQLを投げたい
しかし、やりたい。どこにも書いてない。

以下のようにStandardSQLはまだ推奨はされていない

注: 標準 SQL を使用して BigQuery クエリを記述する機能は、現在ベータ版です。詳細については、クエリ リファレンス(レガシー SQL)をご覧ください。
https://cloud.google.com/bigquery/docs/visualize-datalab?hl=ja#whats-next

私BigQuery 知ッテイルヨソレチガウヨ 的な発言を受けたので、消しておきます。

%%形式

%%sql -d standard
WITH q1 as (
  SELECT count(*)  FROM `myds.logs_*`
)
select * from q1

bigquery module 利用形式

dialect へ standard を指定することで、standard を利用できるようになります。

dialect – {‘legacy’, ‘standard’}, default ‘legacy’ ‘legacy’ : Use BigQuery’s legacy SQL dialect. ‘standard’ : Use BigQuery’s standard SQL (beta), which is compliant with the SQL 2011 standard.
http://googledatalab.github.io/pydatalab/datalab.bigquery.html#datalab.bigquery.Query.to_dataframe

%%sql --module std_sql_sample
WITH q1 as (
  SELECT count(*)  FROM `myds.logs_*`
)
select * from q1
import datalab.bigquery as bq
bq.Query(std_sql_sample).to_dataframe(dialect='standard')

参考

Datalab♡BigQuery

4
1
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1