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

[Bug] Use preserved word as alias in stg_hubspot__contact #124

Open
2 of 4 tasks
papost opened this issue Jan 23, 2024 · 7 comments
Open
2 of 4 tasks

[Bug] Use preserved word as alias in stg_hubspot__contact #124

papost opened this issue Jan 23, 2024 · 7 comments
Labels
status:stale Issue was blocked or had no user response for more than 30 days

Comments

@papost
Copy link

papost commented Jan 23, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the issue

In the stg_hubspot__contact there is the following macro, whose purpose is to rename the columns that have as prefix property and remove it. However, for the column property_delete the result of this transformation is delete. However, this world is preserved leading to unexpected behavior.
{{ fivetran_utils.remove_prefix_from_columns( columns=adapter.get_columns_in_relation(ref('stg_hubspot__contact_tmp')), prefix='property_', exclude=get_macro_columns(get_contact_columns())) }} {% endif %}

Relevant error log or model output

Database Error in model stg_hubspot__contact (models/stg_hubspot__contact.sql)
  001003 (42000): SQL compilation error:
  syntax error line 652 at position 27 unexpected 'DELETE'.
  compiled Code at target/run/hubspot_source/models/stg_hubspot__contact.sql

Expected behavior

The expected behavior is to give a different naming convention to this column. For example, is_contact_deleted

dbt Project configurations

dbt version: 1.7.4
adapter: snowflake 1.7.1

Package versions

Package version 0.14.0

What database are you using dbt with?

snowflake

dbt Version

dbt version: 1.7.4

Additional Context

No response

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

  • Yes.
  • Yes, but I will need assistance and will schedule time during our office hours for guidance
  • No.
@fivetran-jamie
Copy link
Contributor

Hi there! Thanks for the taking the time to file this issue, it definitely makes sense. Couple of questions -- I presume that you have the hubspot__pass_through_all_columns variable set to true?

Also, you mentioned that you'd expect this column to be aliased as is_contact_deleted. I believe there is already a field aliased as such (_fivetran_deleted). Does this value always map onto the value of property_delete? Mostly asking just for my reference

@fivetran-jamie
Copy link
Contributor

i was able to recreate the issue and resolve it by adjusting our macro to wrap the outputted delete field with quotes -- would that be an acceptable solution for you instead of aliasing?

also are you using just the hubspot_source package or also the hubspot transform package? i have a testing branch for either -- if you agree with the above approach and would be interesting in testing it out

@fivetran-jamie
Copy link
Contributor

here are the branches btw

# in packages.yml
packages:
## if only using hubpot_source
- git: https://github.com/fivetran/dbt_hubspot_source.git
  revision: explore/remove-prefix-no-reserved-words
  warn-unpinned: false 
## if using transform (do not include above)
- git: https://github.com/fivetran/dbt_hubspot.git
  revision: explore/remove-prefix-no-reserved-words
  warn-unpinned: false 

@papost
Copy link
Author

papost commented Jan 24, 2024

Hi, and thank you for the response! You correctly presumed that I have the hubspot__pass_through_all_columns variable set to true. You are right about the _fivetran_deleted column, it is aliased as is_contact_deleted, so the delete column is different. Regarding your proposal I don't think it is the best solution, as I said above delete is a preserved word in SQL and under no circumstances should be used, either in quotes or not.

also are you using just the hubspot_source package or also the hubspot transform package? i have a testing branch for either -- if you agree with the above approach and would be interesting in testing it out

I use both of them.

@fivetran-jamie
Copy link
Contributor

Ah yeah you have a very good point.

Question - do you care about having the property_ prefix removed? We originally included it by default because, a while back, Hubspot suddenly added the prefix to people's properties and the change broke their downstream reports

@fivetran-jamie
Copy link
Contributor

just bumping this 😄 @papost

@fivetran-jamie
Copy link
Contributor

marking this as stale for now, but happy to continue thinking this through if folks are interested!

@fivetran-jamie fivetran-jamie added the status:stale Issue was blocked or had no user response for more than 30 days label Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:stale Issue was blocked or had no user response for more than 30 days
Projects
None yet
Development

No branches or pull requests

2 participants