Skip to content

Commit

Permalink
Fixing 'ORDER BY is ignored in subqueries without LIMIT' warning when…
Browse files Browse the repository at this point in the history
… calling `createSccsIntervalData()`. Adding Eunomia unit test using splines
  • Loading branch information
schuemie committed Jun 20, 2024
1 parent 67b26f6 commit d1ac73c
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 16 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: SelfControlledCaseSeries
Type: Package
Title: Self-Controlled Case Series
Version: 5.2.2
Date: 2024-06-10
Version: 5.2.3
Date: 2024-06-20
Authors@R: c(
person("Martijn", "Schuemie", , "[email protected]", role = c("aut", "cre")),
person("Patrick", "Ryan", role = c("aut")),
Expand Down
8 changes: 8 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
SelfControlledCaseSeries 5.2.3
==============================

Bugfixes

1. Fixing 'ORDER BY is ignored in subqueries without LIMIT' warning when calling `createSccsIntervalData()`.


SelfControlledCaseSeries 5.2.2
==============================

Expand Down
4 changes: 1 addition & 3 deletions R/SccsDataConversion.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,12 @@ createSccsIntervalData <- function(studyPopulation,
# Ensure all sorted bv caseId:
cases <- studyPopulation$cases[order(studyPopulation$cases$caseId), ]
outcomes <- studyPopulation$outcomes[order(studyPopulation$outcomes$caseId), ]
eras <- sccsData$eras %>%
arrange(.data$caseId)
data <- Andromeda::andromeda()

convertToSccs(
cases = cases,
outcomes = outcomes,
eras = eras,
eras = sccsData$eras,
includeAge = !is.null(ageCovariateSettings),
ageOffset = settings$ageOffset,
ageDesignMatrix = settings$ageDesignMatrix,
Expand Down
8 changes: 4 additions & 4 deletions src/AndromedaTableIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ using namespace Rcpp;
namespace ohdsi {
namespace sccs {

AndromedaTableIterator::AndromedaTableIterator(const List& _andromedaTable, const bool& _showProgressBar) :
AndromedaTableIterator::AndromedaTableIterator(const List& _andromedaTable, const bool& _showProgressBar, const String& sortColumn) :
progressBar(0),
showProgressBar(_showProgressBar),
completed(0),
done(false) {

Environment dplyr = Environment::namespace_env("dplyr");
if (showProgressBar){
Environment dplyr = Environment::namespace_env("dplyr");
Function count = dplyr["count"];
Function pull = dplyr["pull"];
total = as<int>(pull(count(_andromedaTable)));
Expand All @@ -50,12 +49,13 @@ done(false) {
}
Environment dbplyr = Environment::namespace_env("dbplyr");
Function remote_con = dbplyr["remote_con"];
Function arrange = dplyr["arrange"];
Function sql_render = dbplyr["sql_render"];
Environment dbi = Environment::namespace_env("DBI");
Function dbSendQuery = dbi["dbSendQuery"];

S4 connection = remote_con(_andromedaTable);
String sql = sql_render(_andromedaTable, connection);
String sql = sql_render(arrange(_andromedaTable), connection);
resultSet = dbSendQuery(connection, sql);
}

Expand Down
2 changes: 1 addition & 1 deletion src/AndromedaTableIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace sccs {

class AndromedaTableIterator {
public:
AndromedaTableIterator(const List& _andromedaTable, const bool& _showProgressBar);
AndromedaTableIterator(const List& _andromedaTable, const bool& _showProgressBar, const String& sortColumn);
~AndromedaTableIterator();
bool hasNext();
List next();
Expand Down
2 changes: 1 addition & 1 deletion src/PersonDataIterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace sccs {


PersonDataIterator::PersonDataIterator(const DataFrame& _cases, const DataFrame& _outcomes, const List& _eras) :
erasIterator(_eras, true), casesObservationPeriodStartDate(0), casesCursor(0), outcomesCursor(0), erasCursor(0) {
erasIterator(_eras, true, "caseId"), casesObservationPeriodStartDate(0), casesCursor(0), outcomesCursor(0), erasCursor(0) {

outcomesCaseId = _outcomes["caseId"];
outcomesOutcomeDay = _outcomes["outcomeDay"];
Expand Down
11 changes: 6 additions & 5 deletions tests/testthat/test-eunomia.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,9 @@ test_that("Running multiple analyses against Eunomia", {
endAnchor = "era start"
)

# All outcomes occur at almost the same age, causing issues. Disable for now:
# ageSettings <- createAgeCovariateSettings(ageKnots = 5)
#
# seasonalitySettings <- createSeasonalityCovariateSettings(seasonKnots = 5)
calendarTimeSettings <- createCalendarTimeCovariateSettings(calendarTimeKnots = 5)

seasonalitySettings <- createSeasonalityCovariateSettings(seasonKnots = 5)

covarPreExp <- createEraCovariateSettings(
label = "Pre-exposure",
Expand All @@ -88,7 +87,9 @@ test_that("Running multiple analyses against Eunomia", {
covarExposureOfInt,
covarExposureOfInt2,
covarPreExp
)
),
calendarTimeCovariateSettings = calendarTimeSettings,
seasonalityCovariateSettings = seasonalitySettings
)

fitSccsModelArgs <- createFitSccsModelArgs()
Expand Down

0 comments on commit d1ac73c

Please sign in to comment.