Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chained unnest adds _q_0 in BQ #2125

Closed
z3z1ma opened this issue Aug 30, 2023 · 0 comments
Closed

Chained unnest adds _q_0 in BQ #2125

z3z1ma opened this issue Aug 30, 2023 · 0 comments

Comments

@z3z1ma
Copy link
Contributor

z3z1ma commented Aug 30, 2023

To reproduce

select distinct
    @surrogate_key(u.harness_user_email, d.harness_user_id, harness_account_id) as user_account_key,
    u.harness_user_email,
    d.harness_user_id,
    harness_account_id
from
    analytics_staging.stg_mongodb__users as u,
    unnest(harness_cluster_details) as d,
    unnest(d.harness_account_ids) as harness_account_id
where harness_account_id is not null

The _q_0 should not be here?

SELECT DISTINCT                                                                                                                                                                               
  TO_HEX(                                                                                                                                                                                     
    MD5(                                                                                                                                                                                      
      CONCAT(                                                                                                                                                                                 
        COALESCE(CAST(`u`.`harness_user_email` AS STRING), '_const_'),                                                                                                                        
        '-',                                                                                                                                                                                  
        COALESCE(CAST(`d`.`harness_user_id` AS STRING), '_const_'),                                                                                                                           
        '-',                                                                                                                                                                                  
        COALESCE(CAST(`harness_account_id` AS STRING), '_const_')                                                                                                                             
      )                                                                                                                                                                                       
    )                                                                                                                                                                                         
  ) AS `user_account_key`,                                                                                                                                                                    
  `u`.`harness_user_email` AS `harness_user_email`,                                                                                                                                           
  `d`.`harness_user_id` AS `harness_user_id`,                                                                                                                                                 
  `harness_account_id` AS `harness_account_id`                                                                                                                                                
FROM (<expanded query>) AS `u`, UNNEST(`u`.`harness_cluster_details`) AS `d`, UNNEST(`_q_0`.`d`.`harness_account_ids`) AS `harness_account_id`                                                                      
WHERE                                                                                                                                                                                         
  NOT `harness_account_id` IS NULL   
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant