你好,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
;
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是您要检查的列的名称。这个语句会返回所有在该列中出现重复的行,您可以根据需要进行处理。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
DataWorks基于MaxCompute/Hologres/EMR/CDP等大数据引擎,为数据仓库/数据湖/湖仓一体等解决方案提供统一的全链路大数据开发治理平台。