tnightengale / dbt-activity-schema

A dbt-Core package for generating models from an activity stream.
GNU General Public License v3.0
38 stars 5 forks source link

Compilation Error in model #20

Closed afuyo closed 1 year ago

afuyo commented 1 year ago

I try follow the example in the repo and run this model

{{
    dbt_activity_schema.dataset(
        ref("example__activity_stream"),
        dbt_activity_schema.activity(dbt_activity_schema.all_ever(),"visited page"),
        [
            dbt_activity_schema.activity(
                dbt_activity_schema.first_ever(),
                "signed up",
                ["feature_json", "ts"]
            )
        ]
    )
}}

But get this error

Compilation Error in model first_ever (models\activity_stream\first_ever.sql)
  unsupported operand type(s) for +: 'dict_values' and 'list'
tnightengale commented 1 year ago

@afuyo Confirming: you have uploaded the seed of the example activity stream?

Also, can you provide the project vars you are using, if any?

afuyo commented 1 year ago

@tnightengale Yes, I've uploaded the seed and use no vars at all. It's really juste hello-world dbt-activity-schema ;)

afuyo commented 1 year ago

Here it the entire error message:

Compilation Error in model dataset__first_ever_1 (models/activity_stream/dataset__first_ever_1.sql)
  unsupported operand type(s) for +: 'dict_values' and 'list'

  > in macro dataset (macros/dataset.sql)
  > called by macro default__dataset (macros/dataset.sql)
  > called by model dataset__first_ever_1 (models/activity_stream/dataset__first_ever_1.sql)
wylbee commented 1 year ago

I am getting the same error with the same parameters (default settings) on Snowflake using dbt 1.3. Happy to provide additional logs/info if it would be helpful.

afuyo commented 1 year ago

I was missing these vars in dbt_project.yml in order to make it work. I've added them and I am able to run the examples in the repo.

vars:
  dbt_activity_schema:
    included_columns:
      - activity_id
      - entity_uuid
      - ts
      - revenue_impact
    column_mappings:
      customer: entity_uuid
      anonymous_customer_id: anonymous_entity_uuid
wylbee commented 1 year ago

Thanks @afuyo, declaring the included_columns was the minimum I needed to get the project to compile when using non-example code. Appreciate you sharing the finding on a path forward!

jacobiajohnson commented 1 year ago

@afuyo's solution works well for me until I add feature_json to the list of included_columns. When adding that column I get the following error:

Database Error in rpc request (from remote system.sql) 001044 (42P13): SQL compilation error: 
error line 85 at position 1 
Invalid argument types for function '||': (TIMESTAMP_NTZ(9), OBJECT)

This line appears to be the root of the error. It doesn't know how to combine a timestamp and object type in the concat call.

https://github.com/tnightengale/dbt-activity-schema/blob/main/macros/utils/rendering/render_aggregation.sql#L34

tnightengale commented 1 year ago

Closed by #24