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

get_columns_in_relation return all elements in a field with struct datatype #220

Closed
NikkaIW opened this issue Sep 28, 2021 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@NikkaIW
Copy link

NikkaIW commented Sep 28, 2021

Describe the bug

when using get_columns_in_relation with spark/databricks, I have element in a struct field as a result and not only the struct field

Steps To Reproduce

{%- set yaml_metadata -%}
source_model: 'table'
{%- endset -%}
{% set metadata_dict = fromyaml(yaml_metadata) %}
{% set source_model = metadata_dict['source_model'] %}
{%- set source_relation = ref(source_model) -%}
{%- set source_model_cols = adapter.get_columns_in_relation(source_relation) -%}
{{(source_model_cols)}}

where table has a field with struct datatype such as
address struct<scn:int,from:int,to:int,lines:array<string>,postCode:string>

Expected behavior

I would expect as output
[<SparkColumn address (struct)>]

instead I have
[<SparkColumn address (struct)>, <SparkColumn scn (integer)>, <SparkColumn from (integer)>, <SparkColumn to (integer)>, <SparkColumn lines (array)>, <SparkColumn postCode (string)>]

The output of dbt --version:

installed version: 0.20.2
   latest version: 0.20.2

Up to date!

Plugins:
  - bigquery: 0.20.1
  - snowflake: 0.20.1
  - redshift: 0.20.1
  - postgres: 0.20.1
  - spark: 0.20.2

The operating system you're using: macOS Big Sur

The output of python --version: Python 3.7.9

@NikkaIW NikkaIW added bug Something isn't working triage labels Sep 28, 2021
@jtcohen6
Copy link
Contributor

@NikkaIW Thanks for opening the issue, and sorry for the delay getting back to you!

I've just realized that this is a dupe of #202, which we resolved in #204. So the good news is, you should be able to fix this by upgrading to dbt-spark v0.21.0 :)

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

No branches or pull requests

2 participants