superset icon indicating copy to clipboard operation
superset copied to clipboard

Lack of support for column type tstzrange in PostgreSQL

Open dmelo opened this issue 2 years ago • 4 comments

Superset returns an error when I try a query with a tstzrange column.

How to reproduce the bug

Considering Superset have a connection to a PostgreSQL database and there is a table with at least one column of the type tstzrange, Go to "SQL Lab" -> "SQL Editor" and try a select query that includes the tstzrange column, e.g.: select * from user

Expected results

I expect to see a table with the results from the query

Actual results

An error message:

PostgreSQL Error

Unserializable object [2022-05-06 21:12:02.578651+00:00, None) of type <class 'psycopg2._range.DateTimeTZRange'>

This may be triggered by:
Issue 1002 - The database returned an unexpected error. 

Logs:




2022-05-09 14:33:34,658:INFO:superset.sql_lab:Query 879: Executing 1 statement(s)
--
Query 879: Set query to 'running'
2022-05-09 14:33:34,658:INFO:superset.sql_lab:Query 879: Set query to 'running'
Query 879: Running statement 1 out of 1
2022-05-09 14:33:35,068:INFO:superset.sql_lab:Query 879: Running statement 1 out of 1
[SupersetError(message="Unserializable object [2022-05-06 21:12:02.578651+00:00, None) of type <class 'psycopg2._range.DateTimeTZRange'>", error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR: 'GENERIC_DB_ENGINE_ERROR'>, level=<ErrorLevel.ERROR: 'error'>, extra={'engine_name': 'PostgreSQL', 'issue_codes': [{'code': 1002, 'message': 'Issue 1002 - The database returned an unexpected error.'}]})]
Traceback (most recent call last):
File "/app/superset/views/base.py", line 211, in wraps
return f(self, *args, **kwargs)
File "/app/superset/utils/log.py", line 245, in wrapper
value = f(*args, **kwargs)
File "/app/superset/views/core.py", line 2574, in sql_json
command_result: CommandResult = command.run()
File "/app/superset/sqllab/command.py", line 104, in run
raise ex
File "/app/superset/sqllab/command.py", line 96, in run
status = self._run_sql_json_exec_from_scratch()
File "/app/superset/sqllab/command.py", line 138, in _run_sql_json_exec_from_scratch
raise ex
File "/app/superset/sqllab/command.py", line 133, in _run_sql_json_exec_from_scratch
return self._sql_json_executor.execute(
File "/app/superset/sqllab/sql_json_executer.py", line 111, in execute
raise SupersetErrorsException(
superset.exceptions.SupersetErrorsException: [SupersetError(message="Unserializable object [2022-05-06 21:12:02.578651+00:00, None) of type <class 'psycopg2._range.DateTimeTZRange'>", error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR: 'GENERIC_DB_ENGINE_ERROR'>, level=<ErrorLevel.ERROR: 'error'>, extra={'engine_name': 'PostgreSQL', 'issue_codes': [{'code': 1002, 'message': 'Issue 1002 - The database returned an unexpected error.'}]})]
2022-05-09 14:33:35,871:WARNING:superset.views.base:[SupersetError(message="Unserializable object [2022-05-06 21:12:02.578651+00:00, None) of type <class 'psycopg2._range.DateTimeTZRange'>", error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR: 'GENERIC_DB_ENGINE_ERROR'>, level=<ErrorLevel.ERROR: 'error'>, extra={'engine_name': 'PostgreSQL', 'issue_codes': [{'code': 1002, 'message': 'Issue 1002 - The database returned an unexpected error.'}]})]
Traceback (most recent call last):
File "/app/superset/views/base.py", line 211, in wraps
return f(self, *args, **kwargs)
File "/app/superset/utils/log.py", line 245, in wrapper
value = f(*args, **kwargs)
File "/app/superset/views/core.py", line 2574, in sql_json
command_result: CommandResult = command.run()
File "/app/superset/sqllab/command.py", line 104, in run
raise ex
File "/app/superset/sqllab/command.py", line 96, in run
status = self._run_sql_json_exec_from_scratch()
File "/app/superset/sqllab/command.py", line 138, in _run_sql_json_exec_from_scratch
raise ex
File "/app/superset/sqllab/command.py", line 133, in _run_sql_json_exec_from_scratch
return self._sql_json_executor.execute(
File "/app/superset/sqllab/sql_json_executer.py", line 111, in execute
raise SupersetErrorsException(
superset.exceptions.SupersetErrorsException: [SupersetError(message="Unserializable object [2022-05-06 21:12:02.578651+00:00, None) of type <class 'psycopg2._range.DateTimeTZRange'>", error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR: 'GENERIC_DB_ENGINE_ERROR'>, level=<ErrorLevel.ERROR: 'error'>, extra={'engine_name': 'PostgreSQL', 'issue_codes': [{'code': 1002, 'message': 'Issue 1002 - The database returned an unexpected error.'}]})]

Environment

(please complete the following information):

  • browser type and version: Firefox 100

Using apache/superset:1.5.0

Checklist

Make sure to follow these steps before submitting your issue - thank you!

  • [x] I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • [x] I have reproduced the issue with at least the latest released version of superset.
  • [x] I have checked the issue tracker for the same issue and I haven't found one similar.

dmelo avatar May 09 '22 14:05 dmelo