OHDSI / OHDSI/FeatureExtraction

Java error from getDbCovariateData

Open
#146 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

good first issue
Dominant language
R
Stars
74
Forks
63
PR merge metrics
No merged PRs in 30d

Description

Hello!

After many months of work without this bug, we've recently come across a bug on two separate computers that seem to originate from java.

"Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, :
java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Integer (java.lang.String and java.lang.Integer are in module java.base of loader 'bootstrap')"

We feed a cohort table to getDbCohortMethodData, which calls getDbCovariateData, which in turn calls getDbDefaultCovariateData. Running the code there line-by-line points toward the following call:

rJava::J("org.ohdsi.featureExtraction.FeatureExtraction")$createSql(settings, aggregated, cohortTable, rowIdField, java_array, cdmDatabaseSchema)

We're running sql server, this is the java-version information:

  • openjdk version "16.0.1" 2021-04-20
  • OpenJDK Runtime Environment AdoptOpenJDK-16.0.1+9 (build 16.0.1+9)
  • OpenJDK 64-Bit Server VM AdoptOpenJDK-16.0.1+9 (build 16.0.1+9, mixed mode, sharing)

The input arguments to this rJava::J-function are not very helpful as reproducible example, since a restart of R and feeding the same argument gives you a different error message ("Error in jclassName(class, class.loader = class.loader) : java.lang.ClassNotFoundException"). But here are our input arguments:

settings = '{\"temporal\":false,\"DemographicsGender\":true,\"DemographicsAge\":true,\"ConditionOccurrenceLongTerm\":true,\"ConditionGroupEraLongTerm\":true,\"DrugGroupEraLongTerm\":true,\"longTermStartDays\":-180,\"mediumTermStartDays\":-180,\"shortTermStartDays\":-90,\"endDays\":0,\"includedCovariateConceptIds\":[],\"addDescendantsToInclude\":true,\"excludedCovariateConceptIds\":[\"31317\",\"1139699\"],\"addDescendantsToExclude\":true,\"includedCovariateIds\":[]}' aggregated = FALSE cohortTable = "#cohort_person" rowIdField = "subject_id" java_array = rJava::.jarray(as.character(-1)) cdmDatabaseSchema = "OmopCdm.synpuf5pct_20180710"

If we instead feed a drug_era and condition_era instead of cohort-tables to getDbCohortMethodData, things are working again.
I've also tried to reproduce the bug starting from Eunomia, but the bug does not appear there.

`connection <- DatabaseConnector::connect(Eunomia::getEunomiaConnectionDetails())
DatabaseConnector::executeSql(connection, "DROP TABLE IF EXISTS cohort_table")
DatabaseConnector::executeSql(connection, "CREATE TABLE cohort_table (SUBJECT_ID INT, COHORT_DEFINITION_ID INT, COHORT_START_DATE DATETIME, COHORT_END_DATE DATETIME)")
DatabaseConnector::executeSql(connection, "INSERT INTO cohort_table(SUBJECT_ID, COHORT_DEFINITION_ID, COHORT_START_DATE, COHORT_END_DATE) VALUES (1, 1, '2000-01-01 12:00:00', '2000-01-02 12:00:00')")
DatabaseConnector::querySql(connection, "SELECT * FROM cohort_table")
covSettings <- FeatureExtraction::createCovariateSettings(useConditionGroupEraLongTerm = TRUE, excludedCovariateConceptIds = c(31317, 1139699))

covariateData <- FeatureExtraction::getDbCovariateData(connection = connection,
cdmDatabaseSchema = "main",
cdmVersion = 5,
cohortTable = "cohort_table",
cohortTableIsTemp = FALSE,
rowIdField = "SUBJECT_ID",
covariateSettings = covSettings)
`

Any ideas or input on how to solve this would be highly appreciated. Have there been any recent updates to FeatureExtraction/Java-related matters the last week?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at getDbCohortMethodData, getDbCovariateData, getDbDefaultCovariateData, and the rJava FeatureExtraction$createSql call, using the supplied SQL Server arguments and Java 16 details. Compare the cohort-table path with drug_era/condition_era and the Eunomia reproduction; done means the reported input no longer produces the Java ClassCastException or ClassNotFoundException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, r
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.