OHDSI / circe-be

CIRCE is a cohort definition and syntax compiler tool for OMOP CDMv5
Apache License 2.0
9 stars 13 forks source link

Decimal formatting based on Java locale #184

Closed anthonysena closed 1 year ago

anthonysena commented 1 year ago

Currently when circe-be translates from a JSON specification to SQL, it uses the default locale of the machine to perform the translation. This is problematic in the case when the locale is German since this locale formats a decimal place with a "," instead a ".".

Under these circumstances, a SQL error may be generated. For example, if we were to look for a measurement value < 10, the SQL would be formatted as:

from 
(
  select m.* 
  FROM omopcdm.MEASUREMENT m
JOIN Codesets cs on (m.measurement_concept_id = cs.concept_id and cs.codeset_id = 16)
) C
WHERE C.value_as_number < 10,0000

instead of

from 
(
  select m.* 
  FROM omopcdm.MEASUREMENT m
JOIN Codesets cs on (m.measurement_concept_id = cs.concept_id and cs.codeset_id = 16)
) C
WHERE C.value_as_number < 10.0000

This is a relevant discussion on StackOverflow related to decimal formatting: https://stackoverflow.com/questions/5054132/how-to-change-the-decimal-separator-of-decimalformat-from-comma-to-dot-point.

I'm not sure how we'd want to handle this: either trying to force the locale via Java (which may be hard to do in R) or if we should just assert this in circe-be directly since the target of the translation is ANSI-SQL?