Skip to content

List index out of range error #21

@a-zuniga

Description

@a-zuniga

Our team is using dbt-rockset that leverages this library for its integration. We noticed that there is an index out of range bug when running the command dbt docs generate.

Error message:

21:57:16  Running with dbt=1.5.3
21:57:16  Registered adapter: rockset=0.20.0
21:57:16  Found 14 models, 10 tests, 0 snapshots, 0 analyses, 405 macros, 0 operations, 0 seed files, 17 sources, 0 exposures, 0 metrics, 0 groups
21:57:16
21:57:18  Concurrency: 8 threads (target='dev')
21:57:18
21:57:22  Building catalog
21:57:26  Encountered an error:
list index out of range
21:57:26  Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.10/site-packages/dbt/cli/requires.py", line 86, in wrapper
    result, success = func(*args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/dbt/cli/requires.py", line 71, in wrapper
    return func(*args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/dbt/cli/requires.py", line 142, in wrapper
    return func(*args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/dbt/cli/requires.py", line 168, in wrapper
    return func(*args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/dbt/cli/requires.py", line 215, in wrapper
    return func(*args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/dbt/cli/requires.py", line 250, in wrapper
    return func(*args, **kwargs)
  File "/opt/homebrew/lib/python3.10/site-packages/dbt/cli/main.py", line 273, in docs_generate
    results = task.run()
  File "/opt/homebrew/lib/python3.10/site-packages/dbt/task/generate.py", line 235, in run
    catalog_table, exceptions = adapter.get_catalog(self.manifest)
  File "/opt/homebrew/lib/python3.10/site-packages/dbt/adapters/rockset/impl.py", line 263, in get_catalog
    col_types = self._get_types_in_relation(rel)
  File "/opt/homebrew/lib/python3.10/site-packages/dbt/adapters/rockset/impl.py", line 218, in _get_types_in_relation
    status, table = self.connections.execute(sql, fetch=True)
  File "/opt/homebrew/lib/python3.10/site-packages/dbt/adapters/rockset/connections.py", line 119, in execute
    rows, field_names = self._sql_to_results(cursor, sql)
  File "/opt/homebrew/lib/python3.10/site-packages/dbt/adapters/rockset/connections.py", line 129, in _sql_to_results
    field_names = self._description_to_field_names(cursor.description)
  File "/opt/homebrew/lib/python3.10/site-packages/rockset_sqlalchemy/cursor.py", line 163, in description
    for field_name, field_value in self._response.results[0].items():
IndexError: list index out of range

Potential fix

We were able to track down the bug to the following line:

for field_name, field_value in self._response.results[0].items():

A hacky fix that temporarily unblocked us was to add:

if self._response.results is None or len(self._response.results) == 0:
    return desc

This allowed us to successfully run dbt docs generate without encountering this error. Since this only works locally for us at the moment, we were hoping that this issue could be fixed forward to allow for a more seamless integration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions