Postgresql DB Engine Error: '>=' not supported between instances of 'datetime.timedelta' and 'int'
See original GitHub issueThere seems to be a problem in retrieving and using any column that is of the format: TIMESTAMP WITH TIME ZONE
or just TIMESTAMP
A relational table with a column of type TIMESTAMP WITH TIME ZONE
would error when run a SELECT * ...
or SELECT <column_with_timestamp_type> FROM...
The SQL editor errors even with SELECT now()
The error is:
DB engine Error
postgresql error: '>=' not supported between instances of 'datetime.timedelta' and 'int'
This may be triggered by:
Issue 1002 - The database returned an unexpected error.
Expected results
Would expect the column to return properly and be usable in exploration
Actual results & Screenshots
How to reproduce the bug
- Go to SQL Lab
- run the query:
SELECT now()
Environment
my requirements.txt:
aiohttp==3.7.4.post0
alembic==1.6.5
amqp==2.6.1
apache-superset==1.2.0
apispec==3.3.2
async-timeout==3.0.1
attrs==21.2.0
Babel==2.9.1
backoff==1.11.1
billiard==3.6.4.0
bleach==3.3.1
Brotli==1.0.9
cachelib==0.1.1
celery==4.4.7
cffi==1.14.6
chardet==4.0.0
click==7.1.2
colorama==0.4.4
contextlib2==21.6.0
convertdate==2.3.2
cron-descriptor==1.2.24
croniter==1.0.15
cryptography==3.4.7
decorator==5.0.9
defusedxml==0.7.1
dnspython==2.1.0
email-validator==1.1.3
Flask==1.1.4
Flask-AppBuilder==3.3.1
Flask-Babel==1.0.0
Flask-Caching==1.10.1
Flask-Compress==1.10.1
Flask-JWT-Extended==3.25.1
Flask-Login==0.4.1
Flask-Migrate==3.0.1
Flask-OpenID==1.2.5
Flask-SQLAlchemy==2.5.1
flask-talisman==0.8.1
Flask-WTF==0.14.3
geographiclib==1.52
geopy==2.2.0
graphlib-backport==1.0.3
gunicorn==20.0.4
holidays==0.10.3
humanize==3.10.0
idna==3.2
isodate==0.6.0
itsdangerous==1.1.0
Jinja2==2.11.3
jsonschema==3.2.0
kombu==4.6.11
korean-lunar-calendar==0.2.1
Mako==1.1.4
Markdown==3.3.4
MarkupSafe==2.0.1
marshmallow==3.12.2
marshmallow-enum==1.5.1
marshmallow-sqlalchemy==0.23.1
msgpack==1.0.2
multidict==5.1.0
numpy==1.21.0
packaging==21.0
pandas==1.2.5
parsedatetime==2.6
pathlib2==2.3.6
pgsanity==0.2.9
polyline==1.4.0
prison==0.1.3
psycopg2==2.9.1
py==1.10.0
pyarrow==3.0.0
pycparser==2.20
PyJWT==1.7.1
PyMeeus==0.5.11
pyparsing==2.4.7
pyrsistent==0.18.0
python-dateutil==2.8.2
python-dotenv==0.18.0
python-editor==1.0.4
python-geohash==0.8.5
python3-openid==3.2.0
pytz==2021.1
PyYAML==5.4.1
redis==3.5.3
retry==0.9.2
selenium==3.141.0
simplejson==3.17.3
six==1.16.0
slackclient==2.5.0
SQLAlchemy==1.3.24
SQLAlchemy-Utils==0.36.8
sqlparse==0.3.0
typing-extensions==3.10.0.0
urllib3==1.26.6
vine==1.3.0
webencodings==0.5.1
Werkzeug==1.0.1
WTForms==2.3.3
WTForms-JSON==0.3.3
yarl==1.6.3
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.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:36 (6 by maintainers)
Top Results From Across the Web
[GitHub] [superset] nglglhtr opened a new issue #15768
... now()` The error is: ``` DB engine Error postgresql error: '>=' not supported between instances of 'datetime.timedelta' and 'int' This ...
Read more >TypeError: '>' not supported between instances of 'datetime ...
I need to check this date value is older than 90 days. I tried : from datetime import datetime from datetime import timedelta...
Read more >typeerror not supported between instances of datetime ...
The Python TypeError: '>' not supported between instances of 'datetime.datetime' and 'str' occurs when we try to compare a datetime object and a...
Read more >API Reference — Pony ORM documentation
Database. Database class. Supported databases. SQLite. PostgreSQL. MySQL ... If you'll try to access instance's attributes which were not loaded from the ...
Read more >unsupported operand type(s) for : 'datetime.date' and 'str'
The db engine will get them as datetime for you and the error will be solved. If they're stored as strings in your...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I downgraded the version of psycopg2 and psycopg2-binary to 2.8.6 and the problem was fixed. I assume there is a problem with version 2.9.X.
Work fine after modify postgres db engine, and timezone offset problem in explore solved. Steps with docker-compose instance(version=1.3.1).
psycopg 2.9 release note psycopg2 updated to use
datetime.timezone
astz
property of datetime object, we do not needpytz._FixedOffset
any more.update 2022-01-11
Should have been resolved by this https://github.com/apache/superset/pull/17713