Skip to content

Implement %rowIndex environment variable #11

@johngrimes

Description

@johngrimes

The SQL on FHIR v2 spec defines a %rowIndex environment variable that holds the 0-based index of the current element within the collection being iterated by forEach, forEachOrNull, or repeat. It allows columns to capture position for ordering or surrogate keys.

Spec reference: https://build.fhir.org/ig/FHIR/sql-on-fhir-v2/functional-model.html#the-foreach-and-foreachornull-functions (sections covering the functional model and unionAll interaction with %rowIndex).

Source markdown in the upstream repo: https://github.com/FHIR/sql-on-fhir-v2/blob/master/input/pagecontent/functional-model.md

The corresponding test suite (sqlonfhir/tests/row_index.json) was pulled into this repo by the submodule bump in #9 and currently has nine failing tests against the MSSQL implementation:

  • %rowIndex at top level
  • %rowIndex for surrogate key
  • %rowIndex in unionAll inside forEach
  • %rowIndex in unionAll without forEach
  • %rowIndex with forEach
  • %rowIndex with forEachOrNull
  • %rowIndex with nested forEach
  • %rowIndex with repeat
  • %rowIndex with unionAll

These are not tagged #experimental, so they show up as red in the test report artifact.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions