тип коррелированного шаблона подзапроса не поддерживается из-за внутренней ошибки - PullRequest
0 голосов
/ 28 мая 2018

Я столкнулся с этой ошибкой:

"Этот тип коррелированного шаблона подзапроса не поддерживается из-за внутренней ошибки"

при выполнении следующего запроса для Matillion (инструмент ETL для Redshift).

SELECT DISTINCT
  "sap"."tracking_no" AS "tracking_no",
  (select case when len("sap"."order_create_time")=6 and
                 regexp_instr("sap"."order_create_date",'[a-zA-Z]')=0 and 
                 regexp_instr("sap"."order_create_time",'[a-zA-Z]')=0
            then CAST(CONCAT(CONCAT(cast(isnull("sap"."order_create_date",'1900-01-01') as VARCHAR(10)), ' '),
                   CONCAT(CONCAT(CONCAT(CONCAT(SUBSTRING(isnull("sap"."order_create_time",'000000'), 1,2), ':'),
                   SUBSTRING(isnull("sap"."order_create_time",'000000'), 3,2)),':'),
                   SUBSTRING(isnull("sap"."order_create_time",'000000'), 5,2))) as timestamp)
            when len("sap"."order_create_time")=5 and regexp_instr("sap"."order_create_date",'[a-zA-Z]')=0 and 
                 regexp_instr("sap"."order_create_time",'[a-zA-Z]')=0
            then  CAST(CONCAT(CONCAT(cast(isnull("sap"."order_create_date",'1900-01-01') as VARCHAR(10)), ' '),
                       CONCAT(CONCAT(CONCAT(CONCAT(concat('0',SUBSTRING(isnull("sap"."order_create_time",'000000'), 5,1)), ':'),
                       SUBSTRING(isnull("sap"."order_create_time",'000000'), 3,2)),':'),
                       SUBSTRING(isnull("sap"."order_create_time",'000000'), 5,1))) as timestamp)
            else cast('1900-01-01 000000' as timestamp)
   end)  as "order_date_time",
   (select case when len("sap"."ship_time")=6 and
                 regexp_instr("sap"."ship_date",'[a-zA-Z]')=0 and 
                 regexp_instr("sap"."ship_time",'[a-zA-Z]')=0
            then CAST(CONCAT(CONCAT(cast(isnull("sap"."ship_date",'1900-01-01') as VARCHAR(10)), ' '),
                   CONCAT(CONCAT(CONCAT(CONCAT(SUBSTRING(isnull("sap"."ship_time",'000000'), 1,2), ':'),
                   SUBSTRING(isnull("sap"."ship_time",'000000'), 3,2)),':'),
                   SUBSTRING(isnull("sap"."ship_time",'000000'), 5,2))) as timestamp)
            when len("sap"."ship_time")=5 and regexp_instr("sap"."ship_date",'[a-zA-Z]')=0 and 
                 regexp_instr("sap"."ship_time",'[a-zA-Z]')=0
            then  CAST(CONCAT(CONCAT(cast(isnull("sap"."ship_date",'1900-01-01') as VARCHAR(10)), ' '),
                       CONCAT(CONCAT(CONCAT(CONCAT(concat('0',SUBSTRING(isnull("sap"."ship_time",'000000'), 5,1)), ':'),
                       SUBSTRING(isnull("sap"."ship_time",'000000'), 3,2)),':'),
                       SUBSTRING(isnull("sap"."ship_time",'000000'), 5,1))) as timestamp)
            else cast('1900-01-01 000000' as timestamp)
end)  as "ship_date_time",
  "fedex"."TRACKING_NUMBER" AS "TRACKING_NUMBER"      
FROM fed_ex_feed AS "fedex"
     LEFT OUTER JOIN     
     sap_delivery AS "sap" 
     ON "fedex"."TRACKING_NUMBER" = "sap"."tracking_no"
WHERE sap.order_create_date is not null and
      fedex.DELIVERY_DATE is not null

Я пытался найти разрешения, но не смог найти ни одного разрешения в Интернете.

Это как-то связано с кластером красных смещений, как это следует из внутренней ошибки?

Любая помощь будет оценена.

1 Ответ

0 голосов
/ 29 мая 2018

Я отправляю обновленный запрос, который работает сейчас.Удалите операторы select перед case, и это работает.

SELECT DISTINCT
  "sap"."tracking_no" AS "tracking_no",
   case when len("sap"."order_create_time")=6 and
                 regexp_instr("sap"."order_create_date",'[a-zA-Z]')=0 and 
                 regexp_instr("sap"."order_create_time",'[a-zA-Z]')=0
            then CAST(CONCAT(CONCAT(cast(isnull("sap"."order_create_date",'1900-01-01') as VARCHAR(10)), ' '),
                   CONCAT(CONCAT(CONCAT(CONCAT(SUBSTRING(isnull("sap"."order_create_time",'000000'), 1,2), ':'),
                   SUBSTRING(isnull("sap"."order_create_time",'000000'), 3,2)),':'),
                   SUBSTRING(isnull("sap"."order_create_time",'000000'), 5,2))) as timestamp)
            when len("sap"."order_create_time")=5 and regexp_instr("sap"."order_create_date",'[a-zA-Z]')=0 and 
                 regexp_instr("sap"."order_create_time",'[a-zA-Z]')=0
            then  CAST(CONCAT(CONCAT(cast(isnull("sap"."order_create_date",'1900-01-01') as VARCHAR(10)), ' '),
                       CONCAT(CONCAT(CONCAT(CONCAT(concat('0',SUBSTRING(isnull("sap"."order_create_time",'000000'), 5,1)), ':'),
                       SUBSTRING(isnull("sap"."order_create_time",'000000'), 3,2)),':'),
                       SUBSTRING(isnull("sap"."order_create_time",'000000'), 5,1))) as timestamp)
            else cast('1900-01-01 000000' as timestamp)
   end  as "order_date_time"
   , case when len("sap"."ship_time")=6 and
                 regexp_instr("sap"."ship_date",'[a-zA-Z]')=0 and 
                 regexp_instr("sap"."ship_time",'[a-zA-Z]')=0
            then CAST(CONCAT(CONCAT(cast(isnull("sap"."ship_date",'1900-01-01') as VARCHAR(10)), ' '),
                   CONCAT(CONCAT(CONCAT(CONCAT(SUBSTRING(isnull("sap"."ship_time",'000000'), 1,2), ':'),
                   SUBSTRING(isnull("sap"."ship_time",'000000'), 3,2)),':'),
                   SUBSTRING(isnull("sap"."ship_time",'000000'), 5,2))) as timestamp)
            when len("sap"."ship_time")=5 and regexp_instr("sap"."ship_date",'[a-zA-Z]')=0 and 
                 regexp_instr("sap"."ship_time",'[a-zA-Z]')=0
            then  CAST(CONCAT(CONCAT(cast(isnull("sap"."ship_date",'1900-01-01') as VARCHAR(10)), ' '),
                       CONCAT(CONCAT(CONCAT(CONCAT(concat('0',SUBSTRING(isnull("sap"."ship_time",'000000'), 5,1)), ':'),
                       SUBSTRING(isnull("sap"."ship_time",'000000'), 3,2)),':'),
                       SUBSTRING(isnull("sap"."ship_time",'000000'), 5,1))) as timestamp)
            else cast('1900-01-01 000000' as timestamp)
end  as "ship_date_time",
  "fedex"."TRACKING_NUMBER" AS "TRACKING_NUMBER"      
FROM fed_ex_feed AS "fedex"
     LEFT OUTER JOIN     
     sap_delivery AS "sap" 
     ON "fedex"."TRACKING_NUMBER" = "sap"."tracking_no"
WHERE sap.order_create_date is not null and
      fedex.DELIVERY_DATE is not null
...