Mobius: Spark Sql : 无法隐式将类型"Microsoft.Spark.CSharp.Sql.DataFrame"转换为"System.Collections.IEnumerable"



我正在尝试使用Spark SQL从MySQL表获取一些记录,我在执行该查询时遇到了错误

我想根据列的日期获取数据。

这是我要执行的查询

旧:

spark.sqlContext("select count(*), classification_id, to_date(cast('total_start' as date)) from call_stats where campaign_id = 172 and contact_list_id = 6288 and total_start between '2017-07-06 00:00:00' and '2017-07-07 23:59:00' group by to_date(cast('total_start' as date)) , classification_id").Collect();

这里total_start是我的表列,其中包含DateTime的类型,我想输出作为total_start的日期,total_start的一周,total_start的一个月和total_start的年度

异常

未实施方法或操作

update

将Qyery更改为:

select count(*), classification_id, date_format( cast( total_start as date), 'yyyy-MM-dd') from call_stats where campaign_id = 172 and contact_list_id = 6288 and total_start between '2017-07-06 00:00:00' and '2017-07-07 23:59:00' group by date_format( cast( total_start as date), 'yyyy-MM-dd'), classification_id 

有新的例外:

匿名托管DynamicMethods组装:无法隐式转换类型'Microsoft.spark.csharp.sql.dataframe'转换为" System.Collections.IENUMETION"。存在明确的转换(您是否缺少演员?)

任何帮助将不胜感激

我正在使用一种存在但不正确的方法,因此我只需要更改该查询,例如:

select count(*) as count, classification_id, date_format( cast(total_start as date), 'dd-MM-yyyy')as label from call_stats where campaign_id = 172 and contact_list_id = 6288 and total_start between '2017-07-06 00:00:00' and '2017-07-14 23:59:00' group by date_format( cast(total_start as date), 'dd-MM-yyyy') ,classification_id

,对于一周,月和年,我得到了查询年度的答案:

select count(*) as count, classification_id, year(total_start) as label from call_stats where campaign_id = 172 and contact_list_id = 6288 and total_start between '2015-08-01 00:00:00' and '2017-09-22 23:59:00' group by year(total_start) , classification_id

在一个月的查询示例中为:

select count(*) as count, classification_id, month(total_start) as label from call_stats where campaign_id = 77 and contact_list_id = 6037 and total_start between '2017-04-06 00:00:00' and '2017-05-26 23:59:00' group by month(total_start) , classification_id

在一周的查询示例中:

select count(*) as count, classification_id, weekofyear(total_start) as label from call_stats where campaign_id = 172 and contact_list_id = 6288 and total_start between '2017-07-06 00:00:00' and '2017-07-14 23:59:00' group by weekofyear(total_start) , classification_id

相关内容

  • 没有找到相关文章

最新更新