Visual Data Studio 中的 google bigquery 错误声明变量

Posted

技术标签:

【中文标题】Visual Data Studio 中的 google bigquery 错误声明变量【英文标题】:google bigquery in visual data studio error declare variable 【发布时间】:2020-03-17 13:57:48 【问题描述】:

我在 google BigQuery 上查询相同的代码,它在 google bigquery 上运行良好,然后我复制到视觉数据工作室,它有错误“数据集配置错误”,我不明白这个错误 enter image description here,请帮我。 我认为问题的原因是在 BigQuery 中声明变量

DECLARE yesterday date;
DECLARE count_week01 INT64;--number user active in (last week -1)
DECLARE count_week0 INT64;--number user active in (last week)
DECLARE retention FLOAT64; -- % user has already actived
DECLARE churn_rate FLOAT64; -- % user has already leaved
DECLARE count_user_active_week0 INT64; -- % user has leave
DECLARE week0_begin string; --date begin of last week
DECLARE week0_end string; --date end of last week

DECLARE week01_begin string; --date begin of (last week - 1)
DECLARE week01_end string; --date end of (last week -1)

SET yesterday =  DATE_ADD(CURRENT_DATE(), INTERVAL -1 DAY);

--Set value for last week from yesterday
SET week0_begin =  FORMAT_DATE('%Y%m%d', DATE_ADD(yesterday, INTERVAL -6 DAY));
SET week0_end = FORMAT_DATE('%Y%m%d', yesterday);
--Set value for (last week -1) from yesterday
SET week01_begin =  FORMAT_DATE('%Y%m%d', DATE_ADD(yesterday, INTERVAL -13 DAY));
SET week01_end =   FORMAT_DATE('%Y%m%d', DATE_ADD(yesterday, INTERVAL -7 DAY));

--Count number user active time in last week -1
SET count_week01 = (SELECT COUNT(DISTINCT param.value.string_value) as phone
FROM  `analytics_223664948.events_*` ev,
UNNEST(event_params) AS param
WHERE ev.event_name = 'spl_active_time' and param.key = 'PhoneNumber' AND _TABLE_SUFFIX BETWEEN week01_begin AND week01_end);

--Count number user active time in last week
SET count_week0 = (SELECT COUNT(DISTINCT param.value.string_value) as phone
FROM  `analytics_223664948.events_*` ev,
UNNEST(event_params) AS param
WHERE ev.event_name = 'spl_active_time' and param.key = 'PhoneNumber' AND _TABLE_SUFFIX BETWEEN week0_begin AND week0_end);

--Join last week and last week -1
SET count_user_active_week0 = (SELECT COUNT(week0.phone) FROM
(
  (SELECT DISTINCT param.value.string_value as phone
  FROM  `analytics_223664948.events_*` ev,
  UNNEST(event_params) AS param
  WHERE ev.event_name = 'spl_active_time' and param.key = 'PhoneNumber' AND _TABLE_SUFFIX BETWEEN week0_begin AND week0_end) week0
  INNER JOIN 
  (SELECT DISTINCT param.value.string_value as phone
  FROM  `analytics_223664948.events_*` ev,
  UNNEST(event_params) AS param
  WHERE ev.event_name = 'spl_active_time' and param.key = 'PhoneNumber' AND _TABLE_SUFFIX BETWEEN week01_begin AND week01_end) week01
  ON week0.phone = week01.phone 
)
);
SET retention = 100*count_user_active_week0/count_week01;
SET churn_rate = 100 - retention;

SELECT week01_begin, week01_end, week0_begin, week0_end, count_week0, count_week01, retention, churn_rate

【问题讨论】:

【参考方案1】:

您可以使用 with ...作为 DECLARE 的更改

【讨论】:

以上是关于Visual Data Studio 中的 google bigquery 错误声明变量的主要内容,如果未能解决你的问题,请参考以下文章

visualMap视觉映射组件

这种情况一直在发生 - 在 Visual Studio 2019 中的 .NET Core 3.1 调试会话期间找不到 Microsoft.Data.SqlClient.resources.dll

visual studio C/C++ 编程学习 visual studio 中的生成事件

无法使用 Visual Studio 分发功能注册我的 Xamarin 表单应用程序

google data studio如何收费

如何让 Visual Studio 使用我的数据库,而不是 ASP.NET MVC 项目中 App_Data 文件夹中的 .mdf 文件?