79383199

Date: 2025-01-24 04:08:53
Score: 0.5
Natty:
Report link

When doing UNION with SUPER datatype in redshift, it implicitly converts SUPER data to VARCHAR before calling REGEXP_SUBSTR. This way it loses hierarchical structure

Instead of that below query should work where we are maintaining SUPER struct till it reaches REGEXP_SUBSTR and then explicitly converting datatype of logs.attributes.http.url_details.path to VARCHAR.

with all_logs as (
    (select * from  "xxx"."xxx"."xxx" limit 10)
    union
    (select * from  "xxx"."xxx"."xxx" limit 10))
SELECT
    logs.attributes.http.method AS http_method,
    REGEXP_SUBSTR(logs.attributes.http.url_details.path::VARCHAR, '(firm/)?(v[0-9]/)')
    FROM all_logs as logs

reference: https://docs.aws.amazon.com/redshift/latest/dg/query-super.html#dynamic-typing-lax-processing

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Starts with a question (0.5): When doin
  • Low reputation (1):
Posted by: Rahul Kale