Skip to content

[Bug] redshift json_array_length(super) error #64

@teoria

Description

@teoria

Is there an existing issue for this?

  • I have searched the existing issues

Describe the issue

This error occurs when using Amazon Redshift as your database for the fivetran/facebook_ads dbt package. Redshift's SUPER data type (used for storing raw JSON) requires specific, case-sensitive JSON functions, and json_array_length(super) is either unsupported or improperly applied in this context.

models/facebook_ads__url_tags.sql
on macro get_url_tag_query.sql

  flattened_url_tags as (

      select
          source_relation,
          _fivetran_id,
          creative_id,
          json_extract_array_element_text(required_fields.url_tags, numbers.generated_number::int - 1, true) as element
      from required_fields
      inner join numbers
          on json_array_length(required_fields.url_tags) >= numbers.generated_number
       
  ), 

for redshit i need add json_serialize() function

  flattened_url_tags as (

      select
          source_relation,
          _fivetran_id,
          creative_id,
          json_extract_array_element_text(json_serialize(required_fields.url_tags), numbers.generated_number::int - 1, true) as element
      from required_fields
      inner join numbers
          on json_array_length(json_serialize(required_fields.url_tags) ) >= numbers.generated_number
       
  ), 

Relevant error log or model output

00:46:17  Completed with 1 error and 0 warnings:
00:46:17  
00:46:17    Database Error in model facebook_ads__url_tags (models/facebook_ads__url_tags.sql)
  function json_array_length(super) does not exist
  compiled code at target/run/facebook_ads/models/facebook_ads__url_tags.sql

Expected behavior

the table creation works only with the json_serialize()

Possible solution

flattened_url_tags as (

  select
      source_relation,
      _fivetran_id,
      creative_id,
      json_extract_array_element_text(json_serialize(required_fields.url_tags), numbers.generated_number::int - 1, true) as element
  from required_fields
  inner join numbers
      on json_array_length(json_serialize(required_fields.url_tags) ) >= numbers.generated_number

),

dbt Project configurations

vars:

facebook_ads_schema: 'raw_facebook_ads'
facebook_ads_database: 'dw_v2'

models:
facebook_ads:
#+schema: facebook_ads # default schema suffix
staging:
+schema: facebook_ads_source # default schema suffix

Package versions

  • package: fivetran/ad_reporting
    version: [">=2.4.0", "<2.5.0"]

  • package: fivetran/facebook_ads
    version: 1.4.0

What database are you using dbt with?

redshift

How are you running this dbt package?

dbt Core™

dbt Version

1.11.2

Additional Context

No response

Are you willing to open a PR to help address this issue?

  • Yes.
  • Yes, but I will need assistance.
  • No.

Metadata

Metadata

Labels

type:bugSomething is broken or incorrect

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions