GithubHelp home page GithubHelp logo

Comments (6)

chrisknoll avatar chrisknoll commented on August 10, 2024

Sounds like something related to the R serialization down to the JSON object. When you say 'appear incorrect' does that mean wrong numbers or no numbers?

from achilles.

mdwalter avatar mdwalter commented on August 10, 2024

We are looking into the rendering of the JSON file next but admittedly I don't have much experience with R.

I should have been more specific with what I'm seeing. Here's an example:
The sqlConditionTreemap.sql returns a row with the following values:
percent_persons: 0.17589
records_per_Person: 2.11681

When viewing the table associated with the treemap through the web application that same row shows the following values:
Prevalence; 0.00%
Records per Person: 2.00

The JSON file created for the treemap is consistent with what is displayed on the web application.

from achilles.

chrisknoll avatar chrisknoll commented on August 10, 2024

This looks like an integer rounding issue. I can't say that I've exactly seen this before but it does 'feel' familiar. Basically somewhere along the line it's taking that 0.17 value and it's becoming an integer (0) then converted into a 2 precision float for percentage formatting (0.00). I'm guessing this is the case because of what is happening with the 2.11 becoming 2.00.

from achilles.

kboomhouwer avatar kboomhouwer commented on August 10, 2024

Hi Chris,

We are also facing same issue and we found out the issue is with SQLRENDER. The Treemap SQLs which uses a round function with expression like "round(1.0_ar1.count_value / denom.count_value,5) as percent_persons" is translated as "ROUND(CAST(1.0_ar1.count_value / denom.count_value AS NUMERIC),5) as percent_persons"

Thing to notice here is CAST to NUMERIC is not specified with any precision and scale value. According to Redshift documentation here (http://docs.aws.amazon.com/redshift/latest/dg/r_Numeric_types201.html1) when NUMERIC scale value is not specified it is by default set to zero.

This may require some change in either ACHILESE R package or in SQLRender package. Please suggest your thoughts on this.

from achilles.

schuemie avatar schuemie commented on August 10, 2024

Lovely! In PostgreSQL it is the other way around: if you don't specify the precision, it will allow any type of precision (see here).

I've just changed NUMERIC to FLOAT for RedShift. Could you try updating SqlRender? Close all instances of R, open one instance of R, and do

devtools::install_github("ohdsi/SqlRender")

That should fix the problem.

FYI: the reason for the cast is that PostgreSQL and Redshift do not support all numeric types in their round() function and will cause a crash, even if it is easy to cast the numeric type to something that the function does accept.

from achilles.

mdwalter avatar mdwalter commented on August 10, 2024

Thanks for the update Schuemie. We redeployed the SqlRender component and it fixed the issue with the prevalence calculation.

from achilles.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.