How to query a partitioned table in BigQuery from Tableau

喜夏-厌秋 提交于 2019-12-11 05:29:39

问题


We have a partitioned table in google bigquery that we query using the _PARTITIONTIME field (otherwise the queries will cost too much).

How can I make Tableau use _PARTITIONTIME pseudo column?


回答1:


When configuring your datasource in Tableau, select "Google BigQuery" from the list of available sources, go through the OAuth dance, and then select your project and dataset.

At this point, you will be presented with a list of tables in the dataset, as well as an option to use "New Custom SQL" at the bottom. Select this option, and enter your query exactly as you have been using it. Assuming that the query contains a segment similar to the below:

...WHERE _PARTITIONTIME BETWEEN TIMESTAMP(“2016-05-01”) AND TIMESTAMP(“2016-05-06”)

Now, highlight the dates within that where clause and click on the "Insert Parameter" dropdown menu in the query editor. This will allow you to parameterize your query and dynamically choose the dates you want to query from within your Tableau workbook!

Hopefully this helps!




回答2:


A more flexible solution would be to just drag and drop the table as you would normally. After that click 'datasource - convert to custom SQL' This way tableau has written most of the SQL for you. Last part.... DONT add a where clause and stop user exploration Add this instead:

_PARTITIONTIME AS mypartitiondate

Now you can use this as you would any other date column but you are using partition time instead. Caveats to that are if you use this column you cant drill in below the level of the partitions (eg trying to see hourly trades on a daily partitioned dataset). That would require user knowledge to know to start using another date column for that part instead.



来源:https://stackoverflow.com/questions/39569572/how-to-query-a-partitioned-table-in-bigquery-from-tableau

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!