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] quoting config not working with 1.8 #1074

Closed
2 tasks done
jeremyyeo opened this issue Jun 7, 2024 · 3 comments · Fixed by #1075
Closed
2 tasks done

[Bug] quoting config not working with 1.8 #1074

jeremyyeo opened this issue Jun 7, 2024 · 3 comments · Fixed by #1075
Assignees
Labels
bug Something isn't working High Severity bug with significant impact that should be resolved in a reasonable timeframe regression

Comments

@jeremyyeo
Copy link
Contributor

jeremyyeo commented Jun 7, 2024

Is this a new bug in dbt-snowflake?

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

Current Behavior

The quoting config doesn't quote the database anymore in 1.8 unlike it did pre-1.8.

Expected Behavior

The quoting configs should quote the database like it did pre-1.8.

Steps To Reproduce

  1. Create a database that starts with a number:
create database "1_JYEO";
  1. Use the database in the dbt project with quoting.database = true:
# dbt_project.yml
name: my_dbt_project
profile: all
config-version: 2
version: "1.0.0"

models:
 my_dbt_project:
    +materialized: table
    +database: 1_JYEO

quoting:
  database: true 
-- models/foo.sql
select 1 id
  1. Run on 1.8:
$ dbt --debug run

01:07:44  Sending event: {'category': 'dbt', 'action': 'invocation', 'label': 'start', 'context': [<snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x1046b1510>, <snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x1046efa90>, <snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x1046f7fd0>]}
01:07:44  Running with dbt=1.8.1
01:07:44  running dbt with arguments {'printer_width': '80', 'indirect_selection': 'eager', 'write_json': 'True', 'log_cache_events': 'False', 'partial_parse': 'True', 'cache_selected_only': 'False', 'warn_error': 'None', 'fail_fast': 'False', 'profiles_dir': '/Users/jeremy/.dbt', 'log_path': '/Users/jeremy/git/dbt-basic/logs', 'debug': 'True', 'version_check': 'True', 'use_colors': 'True', 'use_experimental_parser': 'False', 'no_print': 'None', 'quiet': 'False', 'warn_error_options': 'WarnErrorOptions(include=[], exclude=[])', 'introspect': 'True', 'log_format': 'default', 'invocation_command': 'dbt --debug run', 'target_path': 'None', 'static_parser': 'True', 'send_anonymous_usage_stats': 'True'}
01:07:45  Sending event: {'category': 'dbt', 'action': 'project_id', 'label': '7e16f034-b8c9-429a-85e9-e728b206eccf', 'context': [<snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x13518a5d0>]}
01:07:45  Sending event: {'category': 'dbt', 'action': 'adapter_info', 'label': '7e16f034-b8c9-429a-85e9-e728b206eccf', 'context': [<snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x104142590>]}
01:07:45  Registered adapter: snowflake=1.8.2
01:07:45  checksum: ebc509fb14e151ea268e89b60fd5abf912ed99129f87516462718fa2f14f4838, vars: {}, profile: , target: , version: 1.8.1
01:07:45  Unable to do partial parsing because of a version mismatch
01:07:45  Sending event: {'category': 'dbt', 'action': 'partial_parser', 'label': '7e16f034-b8c9-429a-85e9-e728b206eccf', 'context': [<snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x10335f790>]}
01:07:46  Sending event: {'category': 'dbt', 'action': 'load_project', 'label': '7e16f034-b8c9-429a-85e9-e728b206eccf', 'context': [<snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x1353b2750>]}
01:07:46  Sending event: {'category': 'dbt', 'action': 'resource_counts', 'label': '7e16f034-b8c9-429a-85e9-e728b206eccf', 'context': [<snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x136280b90>]}
01:07:46  Found 1 model, 558 macros
01:07:46  Sending event: {'category': 'dbt', 'action': 'runnable_timing', 'label': '7e16f034-b8c9-429a-85e9-e728b206eccf', 'context': [<snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x136451110>]}
01:07:46  
01:07:46  Acquiring new snowflake connection 'master'
01:07:46  Acquiring new snowflake connection 'list_1_JYEO'
01:07:46  Using snowflake connection "list_1_JYEO"
01:07:46  On list_1_JYEO: /* {"app": "dbt", "dbt_version": "1.8.1", "profile_name": "all", "target_name": "sf", "connection_name": "list_1_JYEO"} */
show terse schemas in database "1_JYEO"
    limit 10000
01:07:46  Opening a new connection, currently in state init
01:07:49  SQL status: SUCCESS 3 in 3.0 seconds
01:07:49  On list_1_JYEO: Close
01:07:49  Acquiring new snowflake connection 'list_1_JYEO_dbt_jyeo'
01:07:49  Using snowflake connection "list_1_JYEO_dbt_jyeo"
01:07:49  On list_1_JYEO_dbt_jyeo: /* {"app": "dbt", "dbt_version": "1.8.1", "profile_name": "all", "target_name": "sf", "connection_name": "list_1_JYEO_dbt_jyeo"} */
show objects in 1_JYEO.dbt_jyeo limit 10000
01:07:49  Opening a new connection, currently in state init
01:07:51  Snowflake adapter: Snowflake query id: 01b4d6e3-0804-b779-000d-3783366a862a
01:07:51  Snowflake adapter: Snowflake error: 001003 (42000): SQL compilation error:
syntax error line 1 at position 16 unexpected '1'.
01:07:51  Snowflake adapter: Error running SQL: macro list_relations_without_caching
01:07:51  Snowflake adapter: Rolling back transaction.
01:07:51  On list_1_JYEO_dbt_jyeo: Close
01:07:51  Connection 'master' was properly closed.
01:07:51  Connection 'list_1_JYEO' was properly closed.
01:07:51  Connection 'list_1_JYEO_dbt_jyeo' was properly closed.
01:07:51  
01:07:51  Finished running  in 0 hours 0 minutes and 5.47 seconds (5.47s).
01:07:51  Encountered an error:
Database Error
  001003 (42000): SQL compilation error:
  syntax error line 1 at position 16 unexpected '1'.
01:07:51  Resource report: {"command_name": "run", "command_wall_clock_time": 7.0150514, "process_user_time": 3.133745, "process_kernel_time": 1.425414, "process_mem_max_rss": "202407936", "command_success": false, "process_in_blocks": "0", "process_out_blocks": "0"}
01:07:51  Command `dbt run` failed at 13:07:51.939918 after 7.02 seconds
01:07:51  Sending event: {'category': 'dbt', 'action': 'invocation', 'label': 'end', 'context': [<snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x104717f10>, <snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x104717e90>, <snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x100afc310>]}
01:07:51  Flushing usage events

show objects in 1_JYEO.dbt_jyeo limit 10000 invalid.

  1. Revert to 1.7 and then run again:
$ dbt --debug run

01:08:36  On list_1_JYEO: /* {"app": "dbt", "dbt_version": "1.7.14", "profile_name": "all", "target_name": "sf", "connection_name": "list_1_JYEO"} */
show terse schemas in database "1_JYEO"
    limit 10000
01:08:36  Opening a new connection, currently in state init
01:08:37  SQL status: SUCCESS 3 in 2.0 seconds
01:08:37  On list_1_JYEO: Close
01:08:38  Re-using an available connection from the pool (formerly list_1_JYEO, now list_1_JYEO_dbt_jyeo)
01:08:38  Using snowflake connection "list_1_JYEO_dbt_jyeo"
01:08:38  On list_1_JYEO_dbt_jyeo: /* {"app": "dbt", "dbt_version": "1.7.14", "profile_name": "all", "target_name": "sf", "connection_name": "list_1_JYEO_dbt_jyeo"} */
show terse objects in "1_JYEO".dbt_jyeo limit 10000
01:08:38  Opening a new connection, currently in state closed
01:08:40  SQL status: SUCCESS 2 in 2.0 seconds
01:08:40  On list_1_JYEO_dbt_jyeo: Close
01:08:40  Sending event: {'category': 'dbt', 'action': 'runnable_timing', 'label': '2678a36e-2a7c-4b6c-9c36-a03733b3b4ac', 'context': [<snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x154929ad0>]}
01:08:40  Concurrency: 1 threads (target='sf')
01:08:40  
01:08:40  Began running node model.my_dbt_project.foo
01:08:40  1 of 1 START sql table model 1_JYEO.dbt_jyeo.foo ............................... [RUN]
01:08:40  Re-using an available connection from the pool (formerly list_1_JYEO_dbt_jyeo, now model.my_dbt_project.foo)
01:08:40  Began compiling node model.my_dbt_project.foo
01:08:40  Writing injected SQL for node "model.my_dbt_project.foo"
01:08:40  Timing info for model.my_dbt_project.foo (compile): 13:08:40.768038 => 13:08:40.773299
01:08:40  Began executing node model.my_dbt_project.foo
01:08:40  Writing runtime sql for node "model.my_dbt_project.foo"
01:08:40  Using snowflake connection "model.my_dbt_project.foo"
01:08:40  On model.my_dbt_project.foo: /* {"app": "dbt", "dbt_version": "1.7.14", "profile_name": "all", "target_name": "sf", "node_id": "model.my_dbt_project.foo"} */
create or replace transient table "1_JYEO".dbt_jyeo.foo
         as
        (select 1 id
        );
01:08:40  Opening a new connection, currently in state closed
01:08:42  SQL status: SUCCESS 1 in 2.0 seconds
01:08:42  Timing info for model.my_dbt_project.foo (execute): 13:08:40.773821 => 13:08:42.848314
01:08:42  On model.my_dbt_project.foo: Close
01:08:43  Sending event: {'category': 'dbt', 'action': 'run_model', 'label': '2678a36e-2a7c-4b6c-9c36-a03733b3b4ac', 'context': [<snowplow_tracker.self_describing_json.SelfDescribingJson object at 0x154ada510>]}
01:08:43  1 of 1 OK created sql table model 1_JYEO.dbt_jyeo.foo .......................... [SUCCESS 1 in 2.71s]

show terse objects in "1_JYEO".dbt_jyeo limit 10000 valid.

Relevant log output

No response

Environment

- OS: macOS
- Python: 3.11
- dbt-core: 1.8.2
- dbt-snowflake: 1.8.2

Additional Context

I don't think schema quoting is working either.

1.8:

show objects in {{ schema_relation.database }}.{{ schema_relation.schema }} limit {{ max_results_per_iter }}

1.7:

show objects in {{ schema_relation }} limit {{ max_results_per_iter }}

@jeremyyeo jeremyyeo added bug Something isn't working triage regression labels Jun 7, 2024
@colin-rogers-dbt colin-rogers-dbt added the High Severity bug with significant impact that should be resolved in a reasonable timeframe label Jun 7, 2024
@jtcohen6 jtcohen6 removed the triage label Jun 7, 2024
@ryan-mcnulty-sp
Copy link

I am experiencing something similar when quoting columns on sources. It appears to work on unit_tests but in a dbt build it errors because it looks like quotes are not being added. I see it on 1.8.3 also, which appears to have this bug fix on it. Thanks!

@jeremyyeo
Copy link
Contributor Author

I am experiencing something similar when quoting columns on sources. It appears to work on unit_tests but in a dbt build it errors because it looks like quotes are not being added. I see it on 1.8.3 also, which appears to have this bug fix on it. Thanks!

Do you have a cheeky repro? Unit tests are brand new in 1.8 so it's not really an apples to apples with this issue per se - which is a regression of the quoting config in 1.7 > 1.8. In any case, a quick sense check on:

Core:
  - installed: 1.8.3
  - latest:    1.8.3 - Up to date!
Plugins:
  - snowflake: 1.8.3 - Up to date!
-- create table to test - reserved keyword as col name
create or replace table development_jyeo.dbt_jyeo.raw as (select 1 as "create");
# models/sources.yml
version: 2
sources:
  - name: dbt_jyeo
    tables:
      - name: raw
        columns:
          - name: create
            data_tests:
              - not_null
$ dbt --debug test
22:14:41  On test.my_dbt_project.source_not_null_dbt_jyeo_raw_create.f79610167c: /* {"app": "dbt", "dbt_version": "1.8.3", "profile_name": "all", "target_name": "sf", "node_id": "test.my_dbt_project.source_not_null_dbt_jyeo_raw_create.f79610167c"} */
select
      count(*) as failures,
      count(*) != 0 as should_warn,
      count(*) != 0 as should_error
    from (
      
    
    



select create
from development_jyeo.dbt_jyeo.raw
where create is null



      
    ) dbt_internal_test
22:14:41  Opening a new connection, currently in state closed
22:14:43  Snowflake adapter: Snowflake query id: 01b56876-0905-0194-000d-378339bd9326
22:14:43  Snowflake adapter: Snowflake error: 001003 (42000): SQL compilation error:
syntax error line 12 at position 7 unexpected 'create'.
syntax error line 14 at position 6 unexpected 'create'.
22:14:43  On test.my_dbt_project.source_not_null_dbt_jyeo_raw_create.f79610167c: Close
22:14:44  Database Error in test source_not_null_dbt_jyeo_raw_create (models/sources.yml)
  001003 (42000): SQL compilation error:
  syntax error line 12 at position 7 unexpected 'create'.
  syntax error line 14 at position 6 unexpected 'create'.
  compiled Code at target/run/my_dbt_project/models/sources.yml/source_not_null_dbt_jyeo_raw_create.sql
22:14:44  1 of 1 ERROR source_not_null_dbt_jyeo_raw_create ............................... [ERROR in 2.27s]

Error as expected. Add quote config on column:

version: 2
sources:
  - name: dbt_jyeo
    tables:
      - name: raw
        columns:
          - name: create
            quote: true
            data_tests:
              - not_null
$ dbt --debug test
22:15:46  On test.my_dbt_project.source_not_null_dbt_jyeo_raw__create_.56364b7a58: /* {"app": "dbt", "dbt_version": "1.8.3", "profile_name": "all", "target_name": "sf", "node_id": "test.my_dbt_project.source_not_null_dbt_jyeo_raw__create_.56364b7a58"} */
select
      count(*) as failures,
      count(*) != 0 as should_warn,
      count(*) != 0 as should_error
    from (
      
    
    



select "create"
from development_jyeo.dbt_jyeo.raw
where "create" is null



      
    ) dbt_internal_test
22:15:46  Opening a new connection, currently in state closed
22:15:47  SQL status: SUCCESS 1 in 2.0 seconds
22:15:47  On test.my_dbt_project.source_not_null_dbt_jyeo_raw__create_.56364b7a58: Close
22:15:48  1 of 1 PASS source_not_null_dbt_jyeo_raw__create_ .............................. [PASS in 2.26s]

Works as expected.

This is not a unit test though - not yet familiar with how to set that up.

@ryan-mcnulty-sp
Copy link

Interesting when I do this in my project quote: true doesn't do anything. I do find that I need to delete the target folder anytime I change the related schema.yml file otherwise I get an error about two of the same source. I am on 1.8.4 core and 1.8.3 dbt-snowflake. I will revisit this when I have more time. Thanks for the help here @jeremyyeo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working High Severity bug with significant impact that should be resolved in a reasonable timeframe regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants