Set argument for redshift connection/cursor in order to fetch float instances?
See original GitHub issueDriver version
2.0.905
Redshift version
PostgreSQL 8.0.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3), Redshift 1.0.36224��
Client Operating System
Darwin Nativs-MacBook-Pro.local 21.4.0 Darwin Kernel Version 21.4.0: Mon Feb 21 20:34:37 PST 2022; root:xnu-8020.101.4~2/RELEASE_X86_64 x86_64
Python version
3.8.7
Problem description
I was wondering if there is some kind of a flag / setting I can set in order to tell the connector return a numeric result as float
/ np.float
instead of decimal.Decimal
instance?
I was using the following raw sql on a cursor instance:
cursor.execute("SELECT 1.0 / 7 AS foo")
df = cursor.fetch_dataframe()
output = df.squeeze()
assert not isinstance(output, decimal.Decimal)
Thanks in advance!
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
DECLARE - Amazon Redshift - AWS Documentation
Defines a new cursor within a transaction block. Use a cursor to retrieve a few rows at a time from the result set...
Read more >amazon-redshift-python-driver/cursor.py at master - GitHub
cursor ` method of a connection. (for DQL statements like SELECT) or affected (for DML statements like UPDATE or INSERT). operation is cannot...
Read more >Setting Up Python Redshift Connection: 3 Easy Methods - Learn
In this article, you will see how you can establish a Python Redshift connection to access and query Amazon Redshift data.
Read more >Supported PL/pgSQL statements - Amazon Redshift
To set up a cursor, first you declare a cursor variable. All access to cursors in PL/pgSQL goes through cursor variables, which are...
Read more >Parameter Actions - Tableau Help
For example, a parameter action could show the AVG(Sales) or COUNTD(Orders) for currently selected marks. For examples of how parameter actions can be...
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 Free
Top 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
Hi @ni-todo-spot ,
Small update – I’ve scoped work required for this feature and it looks minimal. I’m working on implementation/testing and anticipate we can include this feature in our next release (scheduled for mid-April). At this time, I think supporting an option for returning a numeric as
float
would be most straight forward.Hey @ni-todo-spot ,
Thanks for reaching out, this is a good question. At this time, all
NUMERIC
values are mapped todecimal.Decimal
.decimal.Decimal
is used forNUMERIC
values as it offer a higher level of precision thanfloat
.I will chat with the Redshift driver team to see if our Redshift JDBC driver offers such an option, and see if this is something we could support. Thank you for your patience 😃