Skip to content

[Bug] Seed fails, if a column has no values #100

Closed
@jpuris

Description

@jpuris

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

When a seed file (csv) has a column with no values, the dbt seed will fail with

max() arg is an empty sequence

Expected Behavior

The seeding is successful

  • the table is created with value-less column
  • data is inserted correctly with value-less column having NULL values

Steps To Reproduce

  1. Add a CSV file in seeds/some_data.csv
    field_1,field_2,field_3
    1,2,
    4,5,
    
  2. Add following to dbt_project.yml
    seeds:
      dbt_project:
        some_data:
          +column_types:
            field_1: number
            field_2: number
            field_3: number
    
  3. Run dbt seed

Relevant log output using --debug flag enabled

17:52:01  While listing relations in database=ORCL, schema=dbt, found: 
17:52:01  Timing info for seed.dbt_project.some_data (execute): 19:52:00.747684 => 19:52:01.390782
17:52:01  On seed.dbt_project.some_data: ROLLBACK
17:52:01  On seed.dbt_project.some_data: Close
17:52:01  Unhandled error while executing 
max() arg is an empty sequence
17:52:01  Traceback (most recent call last):
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/dbt/task/base.py", line 388, in safe_run
    result = self.compile_and_execute(manifest, ctx)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/dbt/task/base.py", line 337, in compile_and_execute
    result = self.run(ctx.node, manifest)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/dbt/task/base.py", line 436, in run
    return self.execute(compiled_node, manifest)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/dbt/task/run.py", line 291, in execute
    result = MacroGenerator(
             ^^^^^^^^^^^^^^^
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/dbt/clients/jinja.py", line 330, in __call__
    return self.call_macro(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/dbt/clients/jinja.py", line 257, in call_macro
    return macro(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/jinja2/runtime.py", line 763, in __call__
    return self._invoke(arguments, autoescape)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/jinja2/runtime.py", line 777, in _invoke
    rv = self._func(*arguments)
         ^^^^^^^^^^^^^^^^^^^^^^
  File "<template>", line 94, in macro
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/jinja2/sandbox.py", line 393, in call
    return __context.call(__obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/jinja2/runtime.py", line 298, in call
    return __obj(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/dbt/clients/jinja.py", line 330, in __call__
    return self.call_macro(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/dbt/clients/jinja.py", line 257, in call_macro
    return macro(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/jinja2/runtime.py", line 763, in __call__
    return self._invoke(arguments, autoescape)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/jinja2/runtime.py", line 777, in _invoke
    rv = self._func(*arguments)
         ^^^^^^^^^^^^^^^^^^^^^^
  File "<template>", line 21, in macro
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/jinja2/sandbox.py", line 393, in call
    return __context.call(__obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/jinja2/runtime.py", line 298, in call
    return __obj(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/dbt/clients/jinja.py", line 330, in __call__
    return self.call_macro(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/dbt/clients/jinja.py", line 257, in call_macro
    return macro(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/jinja2/runtime.py", line 763, in __call__
    return self._invoke(arguments, autoescape)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/jinja2/runtime.py", line 777, in _invoke
    rv = self._func(*arguments)
         ^^^^^^^^^^^^^^^^^^^^^^
  File "<template>", line 44, in macro
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/jinja2/sandbox.py", line 393, in call
    return __context.call(__obj, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/jinja2/runtime.py", line 298, in call
    return __obj(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/dbt/adapters/base/impl.py", line 960, in convert_type
    return cls.convert_agate_type(agate_table, col_idx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/dbt/adapters/base/impl.py", line 975, in convert_agate_type
    return func(agate_table, col_idx)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/my/dbt/project/.venv/lib/python3.11/site-packages/dbt/adapters/oracle/impl.py", line 109, in convert_text_type
    max_len = max(lens) if lens else 64
              ^^^^^^^^^
ValueError: max() arg is an empty sequence

Environment

- OS: macOS 13.5
- Python: Python 3.11.1
- dbt: 1.5.3
- dbt-oracle: 1.5.2

What Oracle database version are you using dbt with?

19c

Additional Context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions