开发者社区 > 大数据与机器学习 > 大数据开发治理DataWorks > 正文

你好,DataWorks 中我编写一个sql报错,为ODPS-0121095:Invalid ?

你好,DataWorks 中我编写一个sql报错,为ODPS-0121095:Invalid argument - ScalarSubQuery not support operate duplicate row, please check your query, the query text location is from [line 11, column 9] to [line 11, column 79] sql:脚本如下:
select sys_source
, sys_source_name
, shop_id
, shop_name
, merchant_code
, contact shop_contact
, phone shop_phone
, shop_status
, shop_status_name
, province_code1 province_code
, (select area_name from dim_misc_area_full where atid = province_code1) province
, city_code
, city
, county_code
, county
, street_code
, street
, address
, license_type
, license_type_name
, license_number
, license_name
, organization_code
, tax_register_code
, lon
, lat
, updated_time
, created_time
, is_food_license
, case is_food_license when 1 then '具有食品经营许可证' when 0 then '无证' else '未知' end is_food_license_name
, general_trade
, case general_trade when 1 then '一般贸易' when 0 then '无贸易模式' else '未知' end general_trade_name
, bonded_trade
, case general_trade when 1 then '报税贸易' when 0 then '无贸易模式' else '未知' end bonded_trade_name
from (
select 'danone' sys_source, '全球臻品优选' sys_source_name, id shop_id, name shop_name, phone, merchant_code,
contact, IF(status = 2, 4, status) shop_status, '' shop_status_name,
-- 通过查询地区表补位
case (length(area_full_code) - length(replace(area_full_code, '-', ''))) when 0 then '' when 1 then split(
area_full_code, '-')[1] when 2 then split(area_full_code, '-')[1] when 3 then split(area_full_code, '-')[
1] else '' end province_code1, '' province,
case (length(area_full_code) - length(replace(area_full_code, '-', ''))) when 0 then '' when 1 then '' when 2 then
split(area_full_code, '-')[2] when 3 then split(area_full_code, '-')[2] else '' end city_code, '' city,
case (length(area_full_code) - length(replace(area_full_code, '-', ''))) when 0 then '' when 1 then '' when 2 then
'' when 3 then split(area_full_code, '-')[3] else '' end county_code, '' county, street_code, '' street,
address, shop_license_type license_type,
case shop_license_type when 1 then '三证' when 2 then '一证' else '未知' end license_type_name,
shop_license_number license_number, shop_license_name license_name, organization_code, tax_register_code, lon, lat,
updated_time, created_time,
if((length(food_circulation_license_img) > 0 or length(food_circulation_license_img_eln) > 0), 1,
0) is_food_license, general_trade, bonded_trade, '' store_area
from ods_danone_user_uc_customer_shop_day
where ds = 20230810
) tmp
;

展开
收起
真的很搞笑 2023-08-22 16:24:29 363 0
1 条回答
写回答
取消 提交回答
  • 全栈JAVA领域创作者

    ODPS-0121095:Invalid argument - ScalarSubQuery not support operate duplicate row
    这个错误是由于在子查询中出现了重复的行。在ODPS中,子查询返回的结果是一个表,如果该表中有重复的行,那么在后续的查询中就会出现错误。
    在您的SQL语句中,子查询返回的结果中可能存在重复的行,因此在后续的查询中出现了错误。您可以检查一下子查询的结果,看看是否存在重复的行。如果存在,您可以尝试使用去重或者其他方法来消除重复行。
    另外,您可以在ODPS中使用以下语句来检查表中是否存在重复行:
    SELECT * FROM table_name WHERE column_name IN (SELECT column_name FROM table_name GROUP BY column_name HAVING COUNT(column_name) > 1);
    其中,table_name是您要检查的表的名称,column_name是您要检查的列的名称。这个语句会返回所有在该列中出现重复的行,您可以根据需要进行处理。

    2023-08-25 07:55:50
    赞同 展开评论 打赏

DataWorks基于MaxCompute/Hologres/EMR/CDP等大数据引擎,为数据仓库/数据湖/湖仓一体等解决方案提供统一的全链路大数据开发治理平台。

相关产品

  • 大数据开发治理平台 DataWorks
  • 热门讨论

    热门文章

    相关电子书

    更多
    DataWorks数据集成实时同步最佳实践(含内测邀请)-2020飞天大数据平台实战应用第一季 立即下载
    DataWorks调度任务迁移最佳实践-2020飞天大数据平台实战应用第一季 立即下载
    基于DataWorks数据服务构建疫情大屏-2020飞天大数据平台实战应用第一季 立即下载