开发者社区 > 大数据与机器学习 > 大数据计算 MaxCompute > 正文

大数据计算MaxCompute这个是查询不了吗?数据太大?

大数据计算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

展开
收起
三分钟热度的鱼 2024-01-10 13:13:54 62 0
2 条回答
写回答
取消 提交回答
  • 根据您提供的错误信息,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;
    

    请注意,这只是一个基本的示例,您可能需要根据实际情况进行调整。

    2024-01-13 10:16:28
    赞同 展开评论 打赏
  • 面对过去,不要迷离;面对未来,不必彷徨;活在今天,你只要把自己完全展示给别人看。

    这个查询是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已经存在并具有正确的结构。

    2024-01-10 13:29:46
    赞同 展开评论 打赏

MaxCompute(原ODPS)是一项面向分析的大数据计算服务,它以Serverless架构提供快速、全托管的在线数据仓库服务,消除传统数据平台在资源扩展性和弹性方面的限制,最小化用户运维投入,使您经济并高效的分析处理海量数据。

相关产品

  • 云原生大数据计算服务 MaxCompute
  • 相关电子书

    更多
    Data+AI时代大数据平台应该如何建设 立即下载
    大数据AI一体化的解读 立即下载
    极氪大数据 Serverless 应用实践 立即下载