Skip to content

Fix #801: Use list() instead of c() to preserve integer type in performanceTable#802

Open
eddy-ccc wants to merge 1 commit intoOHDSI:developfrom
eddy-ccc:fix-801-bigquery-type-coercion
Open

Fix #801: Use list() instead of c() to preserve integer type in performanceTable#802
eddy-ccc wants to merge 1 commit intoOHDSI:developfrom
eddy-ccc:fix-801-bigquery-type-coercion

Conversation

@eddy-ccc
Copy link

Fixes #801

Problem
BigQuery rejects achilles_performance insert because analysis_id is sent as FLOAT64 instead of INT64, returning error:

Error in rJava::.jcall(batchedInsert, "Z", "executeBatch") :
java.sql.SQLException: [Simba][JDBC](11680) Cannot use rollback while Connection is in auto-commit mode.

Root Cause
Line 459 uses c() which coerces all elements to the same type. Since delta, start, and endTime are
numeric (double), c() converts the integer analysisId to numeric.

performanceTable[nrow(performanceTable) + 1, ] <- c(analysisId, delta, start, endTime)

Solution
Changed c() to list() which preserves each element's original type.

performanceTable[nrow(performanceTable) + 1, ] <- list(analysisId, delta, start, endTime)

Tested and confirmed working on BigQuery with DatabaseConnector v7.0.0.

…performanceTable

The c() function coerces all elements to the same type. Since delta, start,
and endTime are numeric (double/FLOAT64), c() converts the integer analysisId
to numeric as well, even though it was explicitly cast to integer.

When DatabaseConnector inserts this data into BigQuery, it sends FLOAT64
parameters, but the achilles_performance.analysis_id column is INT64,
causing BigQuery to reject the insert.

Using list() preserves each element's original type, keeping analysisId
as integer (INT64) for proper BigQuery compatibility.
@bill-baumgartner
Copy link

+1 on this PR. This fix is also needed to run DbDiagnostics::executeDbProfile on BigQuery. Thank you @eddy-ccc for posting the fix!

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