question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Set argument for redshift connection/cursor in order to fetch float instances?

See original GitHub issue

Driver 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:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Brooke-whitecommented, Mar 28, 2022

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.

2reactions
Brooke-whitecommented, Mar 21, 2022

Hey @ni-todo-spot ,

Thanks for reaching out, this is a good question. At this time, all NUMERIC values are mapped to decimal.Decimal. decimal.Decimal is used for NUMERIC values as it offer a higher level of precision than float.

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 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found