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

TypeError: float() argument must be a string or a number, not 'NoneType' when using experimental_python_types=True #269

Closed
1 task done
wolfgangcolsman opened this issue Oct 15, 2022 · 0 comments · Fixed by #281
Labels
bug Something isn't working

Comments

@wolfgangcolsman
Copy link

Expected behavior

None values are mapped to None in _array_map_func

E.g

    def _array_map_func(self, column):
        element_mapping_func = self._col_func(column['arguments'][0]['value'])
        return lambda values: [element_mapping_func(value) if value is not None else None for value in values]

Actual behavior

None in arrays cause TypeError: float() argument must be a string or a number, not 'NoneType'

Steps To Reproduce

query a real array column containing a mix of None and real values

Log output

  File "/usr/local/lib/python3.9/site-packages/trino/dbapi.py", line 435, in execute
    result = self._query.execute()
  File "/usr/local/lib/python3.9/site-packages/trino/client.py", line 758, in execute
    self._result.rows += self.fetch()
  File "/usr/local/lib/python3.9/site-packages/trino/client.py", line 782, in fetch
    return self._row_mapper.map(status.rows)
  File "/usr/local/lib/python3.9/site-packages/trino/client.py", line 982, in map
    return [self._map_row(row) for row in rows]
  File "/usr/local/lib/python3.9/site-packages/trino/client.py", line 982, in <listcomp>
    return [self._map_row(row) for row in rows]
  File "/usr/local/lib/python3.9/site-packages/trino/client.py", line 985, in _map_row
    return [self._map_value(value, self.columns[idx]) for idx, value in enumerate(row)]
  File "/usr/local/lib/python3.9/site-packages/trino/client.py", line 985, in <listcomp>
    return [self._map_value(value, self.columns[idx]) for idx, value in enumerate(row)]
  File "/usr/local/lib/python3.9/site-packages/trino/client.py", line 992, in _map_value
    return col_mapping_func(value)
  File "/usr/local/lib/python3.9/site-packages/trino/client.py", line 892, in <lambda>
    return lambda values: [element_mapping_func(value) for value in values]
  File "/usr/local/lib/python3.9/site-packages/trino/client.py", line 892, in <listcomp>
    return lambda values: [element_mapping_func(value) for value in values]
  File "/usr/local/lib/python3.9/site-packages/trino/client.py", line 907, in <lambda>
    else float(val)
TypeError: float() argument must be a string or a number, not 'NoneType'

Operating System

Bullseye

Trino Python client version

trino-0.318.0

Trino Server version

367

Python version

3.9

Are you willing to submit PR?

  • Yes I am willing to submit a PR!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

2 participants