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]: Dots in the schema name do not parse correctly #203

Closed
1 task done
brock-acryl opened this issue Aug 15, 2023 · 2 comments · Fixed by #205
Closed
1 task done

[Bug]: Dots in the schema name do not parse correctly #203

brock-acryl opened this issue Aug 15, 2023 · 2 comments · Fixed by #205
Labels
bug Something isn't working

Comments

@brock-acryl
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When using a dot (.) in a schema name, dbt will parse this and split out the schema to read:
"samples"."dremio"."com"
instead of
"samples.dremio.com"

Expected Behavior

dbt should parse schema as: "samples.dremio.com"

Steps To Reproduce

Create a schema.yaml file containing the following

sources: 
  - name: samples
    database: Samples
    schema: samples.dremio.com
    tables:
      - name: NYC-weather.csv
      - name: NYC-taxi-trips-iceberg

Environment

- OS: Windows 10 / Mac OSX
- dbt-dremio: commit: 388f540fecde5706d11364caf18937553d31ae13
- Dremio Software: Enterprise 24.1
- Dremio Cloud: 8/15/23

Relevant log output

No response

@brock-acryl brock-acryl added the bug Something isn't working label Aug 15, 2023
@brock-acryl
Copy link
Author

brock-acryl commented Aug 15, 2023

To fix this issue:

Add to line 22
import re

Replace Line 50 with:

PATTERN = re.compile(r'''((?:[^."']|"[^"]*"|'[^']*')+)''') 
return ".".join(PATTERN.split(identifier)[1::2])

Create your schema using double quotes when specifying a single space/folder and single quotes around the entire schema like the following:

sources:
  - name: weather
    database: Samples
    schema: '"samples.dremio.com"'
    tables:
      - name: NYC-weather.csv
  - name: nyc
    database: Samples
    schema: '"samples.dremio.com"."Dremio University"'
    tables:
      - name: sample_data

@lethalazo
Copy link

could you open a PR for the fix you suggested please

brock-acryl added a commit to brock-acryl/dbt-dremio that referenced this issue Sep 6, 2023
@ravjotbrar ravjotbrar mentioned this issue Sep 7, 2023
1 task
@ravjotbrar ravjotbrar linked a pull request Sep 7, 2023 that will close this issue
1 task
ravjotbrar added a commit that referenced this issue Nov 14, 2023
### Summary

Prior to this change, users would not be able to specify a schema with a
dot in it. For instance, schema.parse would get quoted as
"schema"."parse", even though the user intended to quote the entire
identifier. Now users can choose to wrap the schema in single quotes and
add double quotes around the parts they want.

### Description

Add regex to match a pattern containing quotes. Solution provided by
@dremio-brock.

### Test Results

All tests pass.

### Changelog

-   [x] Added a summary of what this PR accomplishes to CHANGELOG.md

### Related Issue

#203
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

2 participants