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] Ensure column name is backticked during alter #1149

Open
2 tasks done
rariyama-k opened this issue Dec 3, 2024 · 0 comments
Open
2 tasks done

[Bug] Ensure column name is backticked during alter #1149

rariyama-k opened this issue Dec 3, 2024 · 0 comments
Labels
bug Something isn't working quoting Issues related to dbt's quoting behavior

Comments

@rariyama-k
Copy link

Is this a new bug in dbt-spark?

  • I believe this is a new bug in dbt-spark
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

When you define a model like the following and execute dbt run, new columns will be added if there are schema changes.

version: 2
models:
  - name: table
    config:
      materialized: incremental
      on_schema_change: append_new_columns
alter table `db`.`schema`.`table`
    add columns (
        new_column string
    )

At this time, if the column name contains a hyphen, it will fail with the following error:

[INVALID_IDENTIFIER] The unquoted identifier column_name is invalid and must be back quoted as: `column_name`.
It would be helpful if you could either add an option to enclose column names with backticks when executing ALTER TABLE, or modify the SQL for ALTER TABLE itself.

Expected Behavior

When executing alter table statement, column name is backticked.

alter table `db`.`schema`.`table`
    add columns (
        `new_column` string
    )

Steps To Reproduce

  1. Create table with hyphen named columns
    create table repro (
         test-c string
    )
  1. Define model file as follows.
version: 2
models:
  - name: table
    config:
      materialized: incremental
      on_schema_change: append_new_columns
  1. Run dbt-run and add new column

Relevant log output

NA

Environment

- OS: macOS Ventura 13.2.1 (22D68)
- Python: Python 3.12.7
- dbt-core: 1.8.5
- dbt-spark: 1.8.0

Additional Context

NA

@rariyama-k rariyama-k added bug Something isn't working triage labels Dec 3, 2024
@amychen1776 amychen1776 added quoting Issues related to dbt's quoting behavior and removed triage labels Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working quoting Issues related to dbt's quoting behavior
Projects
None yet
Development

No branches or pull requests

2 participants