-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
Postgresql DB Engine Error: '>=' not supported between instances of 'datetime.timedelta' and 'int' #15768
Comments
Hi @nglglhtr. |
Hi @nglglhtr I'm not able to reproduce this issue: Can you add some more details reproduction instructions / share a video ideally using the default |
This will be hard to debug / fix if we can't reproduce :( Can you share more context? Are you doing any |
Hi @wildsonc Do you mind share your config file? |
The error occurs in this connected database URI SQLALCHEMY: postgresql+psycopg2://explorernet:[email protected]:5432/web_caixas No other options are checked in connection settings. |
Facing the same issue with the instance on superset , has there been any patches released recently ? I'm not able to upload the error but its pretty much the same as posted in some of the above posts |
Not really, I'm simply trying to query a database that consists of a column of type timestamp |
Some more context:
|
Same issue here. Docker instance had no issues with connecting to local postgres db but my local install of apache-superset installed via pip in venv yielded the following error despite successful connection w/ postgresql instance:
And here is the query (very simple w/o any relational operators): SELECT *
FROM pulse_ox_moving_average; Here are the only packages installed in the venv, apart from apache-superset, I installed psycopg2 and that is all. requirements.txt |
After further experimentation, the issue seems to be timezones. If I removed the timezone offset with to_char(), my query works. Update: I was able to work around the issue with the following query: SELECT (time at time zone 'CEST')::timestamp without time zone AS "time",
ma_spo2,
ma_bpm,
ma_perf
FROM pulse_ox_moving_average This hack would allow me to create time-series charts where as using to_char would not. Setting a timezone and then localizing by removing the timezone is not ideal for the long term. |
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. |
That did the trick. Very much appreciated. ✔️ |
Dowgrading from 2.9.1 -> 2.8.6 was also the solution in my case. Could quite possibly be related to this change listed in the 2.9 release notes?
|
Following on your suggestion, I fixed it by editing the date column expression in the dataset editor window:
|
I can replicate this issue using a fresh install of the latest docker image per the instructions here. Screenshot below. According to a pip freeze in the app container (superset_app), this version is using psycopg2 v. 2.9.1. Manually replacing version 2.9.1 with 2.8.6 as suggested above resolves the issue. @mail2lawi's solution above (time at time zone 'CEST')... also was an effective fix, leading me to support the hypothesis that this issue is specifically related to columns which contain timestamptz values. Thank you for your help all! |
I am getting this error on the current master branch...
I am connecting to postgresql 11.10. Here is what I see in my logs...
The error is...
This is the DDL for the main timestamp field...
|
The error seems to be related the following code...
The minutes variable is a datetime.timedelta object, which is not compatible with the '>=' operator against and int, in python. |
Hi @jonathanStrange0 , I'm new to superset. What are the steps to change the version with docker-compose. |
You should just be able to:
|
As a work-around I convert the date to a string.
use...
The actual error does not seem to come from the Postgres server as indicated by the error message. |
String solution does not work well, it will cause other problems with some visualizations. The real issue is that (with Postgres) dates can be missing the timezone in some way, and forcing a timezone into the output field fixes the date issue properly without making it a string. Making the main temporal date field into a string, will cause other problems. So, for date fields, don't use... |
Same problem happens when using "Big Number with Trendline" and doing a |
…b engine with psycopg2==2.9.1
Work fine after modify postgres db engine, and timezone offset problem in explore solved. docker exec -it superset_app /bin/bash
apt-get update
apt-get install vim
vim /app/superset/db_engine_specs/postgres.py
# delete line 171 (cursor.tzinfo_factory = FixedOffsetTimezone)
exit
# back to host machine
docker-compose -f docker-compose-non-dev.yml restart psycopg 2.9 release note update 2022-01-11 Should have been resolved by this #17713 |
How to do it? What all files to change and what command to fire after changing version in files. |
Is this an issue that will be fixed soon? |
Maybe label should be changed ? Feel like this is being forgotten because of that. |
* bump py version for integration test * bump py * bump py * remove files * lock pylint * add not-callable
This fix did not work for me. But reverting psycopg2-binary to 2.8.5 solved my problem. |
This solution works for me but this solution seems better: #15768 (comment) |
Hi ! For docker-compose-non-dev, here is my "hack":
Before the hackAfter the hack |
For me, this didn't work. I found this "hack" : #15768 (comment)
|
This library (psycopg2-binary) was not installed at all.
|
Glad to see there are workarounds possible, however I'd prefer to use the official Docker image posted to Dockerhub. Any idea when this fix can be made available there? |
I also had the same issue and downgrading psycopg2 from 2.9.1 to 2.8.6 did fix it. |
This has been fixed on master branch here: #17713 , closing |
Issue with psycopg2 version workaround: apache/superset#15768 Fixed in (unreleased) Superset: apache/superset#17713
* Downgrade pyscopg2 to 2.8.6, because 2.9 use datetime.timezone as tz property of datetime object, we do not need pytz._FixedOffset any more See details at [What’s new in psycopg 2.9](https://www.psycopg.org/docs/news.html#what-s-new-in-psycopg-2-9).
There seems to be a problem in retrieving and using any column that is of the format:
TIMESTAMP WITH TIME ZONE
or justTIMESTAMP
A relational table with a column of type
TIMESTAMP WITH TIME ZONE
would error when run aSELECT * ...
orSELECT <column_with_timestamp_type> FROM...
The SQL editor errors even with
SELECT now()
The error is:
Expected results
Would expect the column to return properly and be usable in exploration
Actual results & Screenshots
How to reproduce the bug
SELECT now()
Environment
my requirements.txt:
Checklist
Make sure to follow these steps before submitting your issue - thank you!
The text was updated successfully, but these errors were encountered: