大数据计算MaxCompute这个是查询不了吗?数据太大?ODPS-1850001: Unsupported feature in session mode - Non select query not supported.INSERT OVERWRITE TABLE fz_bigdata.dw_user_property_di PARTITION (dt= '20240102')
SELECT user_id,
'cookie' as user_type,
MAX(phone) as phone,
MAX(username) as username,
MAX(CASE WHEN username IS NOT NULL AND username <> '' THEN '有' END) AS is_username,
arg_max(dt, gender ) filter (where gender is not null) as gender,
arg_max(dt, c_gender ) filter (where c_gender is not null) as c_gender,
arg_max(dt, birthday ) filter (where birthday is not null) as birthday,
arg_max(dt, hour ) filter (where hour is not null) as hour,
arg_max(dt, age ) filter (where age is not null) as age,
arg_max(dt, zodiac ) filter (where zodiac is not null) as zodiac,
array_distinct(flatten(collect_list(births))) as births,
array_distinct(flatten(collect_list(loves))) as loves,
array_distinct(flatten(collect_list(citys))) as citys,
array_distinct(flatten(collect_list(provinces))) as provinces,
array_distinct(flatten(collect_list(channels))) as channels,
array_distinct(flatten(collect_list(result_page_three_view_product_types))) as result_page_three_view_product_types,
array_distinct(flatten(collect_list(result_page_pay_product_types))) as result_page_pay_product_types,
array_distinct(flatten(collect_list(result_page_repurchase_product_types))) as result_page_repurchase_product_types,
arg_max(dt, is_result_page_repurchase ) filter (where is_result_page_repurchase is not null) as is_result_page_repurchase,
arg_max(dt, red_packet_use ) filter (where red_packet_use is not null) as red_packet_use
FROM fz_bigdata.dw_user_property_di WHERE dt in ('20240101','20231231' )
group by user_id
根据您提供的错误信息,ODPS-1850001表示会话模式下不支持的非选择查询。这表明您正在尝试使用INSERT OVERWRITE语句进行非选择查询,这是MaxCompute会话模式所不支持的操作。
在MaxCompute中,INSERT OVERWRITE通常用于将查询结果覆盖写入到表中,但要求查询必须是SELECT查询。如果您需要进行复杂的转换操作,可以考虑使用SQL的其他功能,如窗口函数(如ROW_NUMBER()),或者将查询结果临时存储在一个中间表中,然后再进行插入操作。
例如,您可以创建一个临时表来保存查询结果,然后通过INSERT OVERWRITE语句将临时表的数据写入目标表。以下是一个示例:
-- 创建临时表
CREATE TEMPORARY TABLE temp_table AS
SELECT user_id,
...
FROM fz_bigdata.dw_user_property_di
WHERE dt in ('20240101','20231231');
-- 将临时表的数据写入目标表
INSERT OVERWRITE TABLE fz_bigdata.dw_user_property_di PARTITION (dt= '20240102')
SELECT * FROM temp_table;
请注意,这只是一个基本的示例,您可能需要根据实际情况进行调整。
这个查询是MaxCompute的SQL语法,用于在大数据计算中执行数据查询。它从表fz_bigdata.dw_user_property_di中选择数据,并对结果进行分组和聚合操作。
然而,根据您提供的错误信息"ODPS-1850001: Unsupported feature in session mode - Non select query not supported.",可以看出该查询不支持在会话模式下执行非SELECT查询。这意味着您无法直接在MaxCompute中使用INSERT OVERWRITE语句来覆盖表fz_bigdata.dw_user_property_di的数据。
如果您需要将查询结果写入表fz_bigdata.dw_user_property_di,您可以使用INSERT INTO语句来实现。以下是一个示例代码片段:
INSERT INTO fz_bigdata.dw_user_property_di (user_id, user_type, phone, username, is_username, gender, c_gender, birthday, hour, age, zodiac, births, loves, citys, provinces, channels, result_page_three_view_product_types, result_page_pay_product_types, result_page_repurchase_product_types, is_result_page_repurchase, red_packet_use)
SELECT user_id,
'cookie' as user_type,
MAX(phone) as phone,
MAX(username) as username,
MAX(CASE WHEN username IS NOT NULL AND username <> '' THEN '有' END) AS is_username,
arg_max(dt, gender ) filter (where gender is not null) as gender,
arg_max(dt, c_gender ) filter (where c_gender is not null) as c_gender,
arg_max(dt, birthday ) filter (where birthday is not null) as birthday,
arg_max(dt, hour ) filter (where hour is not null) as hour,
arg_max(dt, age ) filter (where age is not null) as age,
arg_max(dt, zodiac ) filter (where zodiac is not null) as zodiac,
array_distinct(flatten(collect_list(births))) as births,
array_distinct(flatten(collect_list(loves))) as loves,
array_distinct(flatten(collect_list(citys))) as citys,
array_distinct(flatten(collect_list(provinces))) as provinces,
array_distinct(flatten(collect_list(channels))) as channels,
array_distinct(flatten(collect_list(result_page_three_view_product_types))) as result_page_three_view_product_types,
array_distinct(flatten(collect_list(result_page_pay_product_types))) as result_page_pay_product_types,
array_distinct(flatten(collect_list(result_page_repurchase_product_types))) as result_page_repurchase_product_types,
arg_max(dt, is_result_page_repurchase ) filter (where is_result_page_repurchase is not null) as is_result_page_repurchase,
arg_max(dt, red_packet_use ) filter (where red_packet_use is not null) as red_packet_use
FROM fz_bigdata.dw_user_property_di WHERE dt in ('20240101','20231231' )
group by user_id;
请注意,上述代码中的列名和表名可能需要根据您的实际情况进行调整。另外,确保您的MaxCompute账户具有足够的权限来执行INSERT INTO语句,并且目标表fz_bigdata.dw_user_property_di已经存在并具有正确的结构。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
MaxCompute(原ODPS)是一项面向分析的大数据计算服务,它以Serverless架构提供快速、全托管的在线数据仓库服务,消除传统数据平台在资源扩展性和弹性方面的限制,最小化用户运维投入,使您经济并高效的分析处理海量数据。