apache / superset

Apache Superset is a Data Visualization and Data Exploration Platform

Home Page:https://superset.apache.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lack of support for column type tstzrange in PostgreSQL

dmelo opened this issue · 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!

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

@dmelo Did you get anywhere with this? I am encountering a similar issue with timestamptz columns

Hi @dheardal . Yes. I have changed the code to interpret the column type that was causing the problem. I have opened a PR. Perhaps this is useful to you as well.

Thanks for the PR on this @dmelo - can you validate if this is still an issue in Superset 3.x? If so, hopefully we can touch up that PR and get it through.

would defs appreciate this fix!!

Using development mode on the master branch, with PosgreSQL 16, I can see that Superset is supporting tstzrange. I guess somebody else implemented this 😄

Looking a little into the code, I think it was fixed here #23865 .

I'm closing this issue.

2024-04-11_08-47