Skip to content

Commit

Permalink
ir generation results are now exported correctly (#1767)
Browse files Browse the repository at this point in the history
queryForRowSet function calls isSigned function which is not implemented for hive
fixes #1765

Co-authored-by: Sergey Suvorov <[email protected]>
  • Loading branch information
ssuvorov-fls and ssuvorov-fls authored Feb 5, 2021
1 parent 58573d7 commit d7064cc
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions src/main/java/org/ohdsi/webapi/service/IRAnalysisService.java
Original file line number Diff line number Diff line change
Expand Up @@ -685,28 +685,27 @@ public Response export(final int id) {
String distQuery = String.format("select '%s' as db_id, target_id, outcome_id, strata_sequence, dist_type, total, avg_value, std_dev, min_value, p10_value, p25_value, median_value, p75_value, p90_value, max_value from %s.ir_analysis_dist where analysis_id = %d", source.getSourceKey(), resultsTableQualifier, id);
String translatedSql = SqlTranslate.translateSql(distQuery, source.getSourceDialect(), SessionUtils.sessionId(), resultsTableQualifier);

SqlRowSet rs = this.getSourceJdbcTemplate(source).queryForRowSet(translatedSql);

if (distLines.isEmpty())
{
distLines.add(rs.getMetaData().getColumnNames());
}
while (rs.next())
{
ArrayList<String> columns = new ArrayList<>();
for(int i = 1; i <= rs.getMetaData().getColumnNames().length; i++)
{
switch (rs.getMetaData().getColumnName(i)) {
case "dist_type":
columns.add(distTypeLookup.get(rs.getInt(i)));
this.getSourceJdbcTemplate(source).query(translatedSql, resultSet -> {
if (distLines.isEmpty()) {
ArrayList<String> columnNames = new ArrayList<>();
for(int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) {
columnNames.add(resultSet.getMetaData().getColumnName(i));
}
distLines.add(columnNames.toArray(new String[0]));
}
ArrayList<String> columnValues = new ArrayList<>();
for(int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) {
switch (resultSet.getMetaData().getColumnName(i)) {
case "dist_type":
columnValues.add(distTypeLookup.get(resultSet.getInt(i)));
break;
default:
columns.add(rs.getString(i));
columnValues.add(resultSet.getString(i));
break;
}
}
distLines.add(columns.toArray(new String[0]));
}
}
distLines.add(columnValues.toArray(new String[0]));
});
}

// Write report lines to CSV
Expand Down

0 comments on commit d7064cc

Please sign in to comment.