cube-js / cube_dbt

dbt integration for Cube
7 stars 2 forks source link

added optional encoding parameter for Dbt.from_file() and docstring to from_file() and from_url() #6

Closed samuelberntzen closed 6 months ago

samuelberntzen commented 6 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.

samuelberntzen commented 6 months ago

Added commits which changed file format back to original structure, due to my IDE formatter altering the entire file.