cube-js / cube_dbt

dbt integration for Cube
7 stars 3 forks source link

added encoding option, docstring and kept format of original file #7

Open samuelberntzen opened 7 months ago

samuelberntzen commented 7 months ago

I encountered encoding error while testing Cube Core and trying to load my manifest.json from file. My manifest.json file was utf-8 encoded, which caused UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 10168:.

Python version 3.9 which Cube Core docker image is using defaults to locale.getprefferedencoding(), which seems to be ascii on the docker image of Cube Core.

Example of usage with Dbt.from_file():

from cube_dbt import Dbt

# with utf-8 encoding
dbt = Dbt.from_file("path/to/manifest.json", encoding="utf-8").filter(paths=["marts/"])

# without specifying encoding
dbt = Dbt.from_file("path/to/manifest.json").filter(paths=["marts/"])

Not needed in from_url() method because urlopen uses Content-Type headers to set encoding.

** new PR from new branch to prevent too many file edits