Skip to content
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

Handle decimal types in query results #6837

Merged
merged 2 commits into from
Mar 29, 2024

Conversation

wlach
Copy link
Contributor

@wlach wlach commented Mar 28, 2024

What type of PR is this?

  • Refactor
  • Feature
  • Bug Fix
  • New Query Runner (Data Source)
  • New Alert Destination
  • Other

Description

Since #6687, we don't serialize query results as JSON before returning them. This is fine, except for the
query results data source which needs to pass the data directly to sqlite3, and doesn't know how to
do that with the decimal types that are occasionally returned by (at least) the PostgreSQL query runner:

https://www.psycopg.org/docs/faq.html#problems-with-type-conversions

How is this tested?

  • Unit tests (pytest, jest)
  • E2E Tests (Cypress)
  • Manually
  • N/A

Related Tickets & Documents

N/A

Mobile & Desktop Screenshots/Recordings (if there are UI changes)

Since getredash#6687, we don't serialize query results as JSON
before returning them. This is fine, except for the
query results data source which needs to pass the
data directly to sqlite3, and doesn't know how to
do that with the decimal types that are occasionally
returned by (at least) the PostgreSQL query runner:

https://www.psycopg.org/docs/faq.html#problems-with-type-conversions
}
table_name = "query_123"
create_table(connection, table_name, results)
connection.execute("SELECT 1 FROM query_123")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified that this fails without the above fix applied.

Copy link

codecov bot commented Mar 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.43%. Comparing base (c4d3d9c) to head (cf25a24).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6837   +/-   ##
=======================================
  Coverage   63.42%   63.43%           
=======================================
  Files         163      163           
  Lines       13203    13206    +3     
  Branches     1823     1824    +1     
=======================================
+ Hits         8374     8377    +3     
  Misses       4531     4531           
  Partials      298      298           
Files Coverage Δ
redash/query_runner/query_results.py 62.40% <100.00%> (+0.86%) ⬆️

@wlach
Copy link
Contributor Author

wlach commented Mar 28, 2024

@eradman @justinclift Can you take a look?

Copy link
Member

@justinclift justinclift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds sensible to me. 😄

@justinclift justinclift merged commit 2441986 into getredash:master Mar 29, 2024
13 checks passed
@wlach wlach deleted the fix-query-results-decimals branch March 29, 2024 12:07
@wlach wlach mentioned this pull request Apr 2, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants