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

dbt Server errors when returning Array types in Postgres #2337

Closed
1 task done
drewbanin opened this issue Apr 16, 2020 · 1 comment · Fixed by #2376
Closed
1 task done

dbt Server errors when returning Array types in Postgres #2337

drewbanin opened this issue Apr 16, 2020 · 1 comment · Fixed by #2376
Labels
bug Something isn't working redshift rpc Issues related to dbt's RPC server

Comments

@drewbanin
Copy link
Contributor

Describe the bug

There's some sort of agate-internal issue with converting array type columns to an Agate dataframe from a Postgres response. TBD what the exact culprit is, but it manifests as tuple.index(x): x not in tuple called via agate_table.table_from_data (specifically in table.select(column_names)). There's a solid reproduction case attached below.

Steps To Reproduce

Run the query:

select ARRAY[10000, 10000, 10000, 10000]

against a running rpc server. Poll for a response and see the error:

Traceback (most recent call last):
  File \"/Users/drew/fishtown/dbt/core/dbt/node_runners.py\", line 227, in safe_run
    result = self.compile_and_execute(manifest, ctx)
  File \"/Users/drew/fishtown/dbt/core/dbt/node_runners.py\", line 170, in compile_and_execute
    result = self.run(ctx.node, manifest)
  File \"/Users/drew/fishtown/dbt/core/dbt/node_runners.py\", line 272, in run
    return self.execute(compiled_node, manifest)
  File \"/Users/drew/fishtown/dbt/core/dbt/rpc/node_runners.py\", line 86, in execute
    compiled_node.injected_sql, fetch=True
  File \"/Users/drew/fishtown/dbt/core/dbt/adapters/base/impl.py\", line 227, in execute
    fetch=fetch
  File \"/Users/drew/fishtown/dbt/core/dbt/adapters/sql/connections.py\", line 119, in execute
    table = self.get_result_from_cursor(cursor)
  File \"/Users/drew/fishtown/dbt/core/dbt/adapters/sql/connections.py\", line 110, in get_result_from_cursor
    return dbt.clients.agate_helper.table_from_data(data, column_names)
  File \"/Users/drew/fishtown/dbt/core/dbt/clients/agate_helper.py\", line 84, in table_from_data
    return table.select(column_names)
  File \"/Users/drew/fishtown/dbt/env/lib/python3.7/site-packages/agate/table/select.py\", line 21, in select
    indexes = tuple(self._column_names.index(k) for k in key)
  File \"/Users/drew/fishtown/dbt/env/lib/python3.7/site-packages/agate/table/select.py\", line 21, in <genexpr>
    indexes = tuple(self._column_names.index(k) for k in key)
ValueError: tuple.index(x): x not in tuple

Expected behavior

I'd expect this query to return data successfully. The Array field should be json-ified, as with non-primitive types on other datbases (BQ, Snowflake).

System information

Which database are you using dbt with?

  • postgres

The output of dbt --version:

0.16.0
@drewbanin drewbanin added bug Something isn't working redshift rpc Issues related to dbt's RPC server labels Apr 16, 2020
@drewbanin drewbanin added this to the Octavius Catto milestone Apr 16, 2020
@drewbanin
Copy link
Contributor Author

Update:

select ARRAY[10000, 10000, 10000, 10000]
ipdb> table.print_table()
| array/0 | array/1 | array/2 | array/3 |
| ------- | ------- | ------- | ------- |
|  10,000 |  10,000 |  10,000 |  10,000 |

Thanks, Agate!

iknox-fa pushed a commit that referenced this issue Feb 8, 2022
automatic commit by git-black, original commits:
  0781cef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working redshift rpc Issues related to dbt's RPC server
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant