Skip to content

GCAM-Europe double slash queries work for GCAM-core regions but not for GCAM-Europe regions #93

@klau506

Description

@klau506

rgcam::runQuery() fails for GCAM-Europe regions but works for GCAM-core regions

When running queries that require double slash through rgcam, rgcam::runQuery(conn, co2_query, scenario, reg), the function fails whenever reg corresponds to a GCAM-Europe region, while it runs correctly for GCAM-core regions.

For example, if we introduce a double slash between subsector and technology:

co2_query <- "<emissionsQueryBuilder title=\"CO2 emissions by tech (nested subsector) (excluding resource production)\"> <axis1 name=\"technology\">technology</axis1> <axis2 name=\"Year\" optional=\"true\">emissions</axis2> <xPath buildList=\"true\" dataName=\"emissions\" group=\"false\" sumAll=\"false\" optional=\"true\"> *[@type = 'sector' ]/*[@type='subsector']//*[@type='technology')]//CO2/emissions/node() </xPath> <comments/> </emissionsQueryBuilder>"

The same query runs successfully in Model Interface, but fails in the rgcam package when querying GCAM-Europe regions.

Inspecting the output using the MI, we observed two irregularities when running the query with and without the double slash between subsector and technology:

1. Different values for some sector–subsector–technology entries

Example output differences:

scenarioregionsectorsubsectortechnology 199020052010201520202025 203020352040204520502065 20802095Units
Ref (query with single slash)Spainaluminagasgas 0.006621930.003990820.05291310.07721930.08891540.09128569 0.086938930.077469660.06751530.060895160.056721945000MTC
Ref (query with double slash)Spainaluminagasgas 0.013243860.007981640.10582620.15443860.17783080.18257138 0.173877860.154939320.13503060.121790320.11344389000MTC

2. New EU electricity-grid-related sectors missing unless // is used in XPath

The GCAM-Europe version introduces new electricity-grid sectors, which are base load generation, intermediate generation, peak generation, and subpeak generation. These only appear when XPath includes a double slash.


The exact error message when running:

rgcam::runQuery(conn, co2_query, scenario, "Spain")

is:

About to perform query: collection()/scenario About to perform query: collection()/scenario[ (@name='EU_NECP_LTT-Rev1' and @date='2025-10-11T09:44:43+01:00') ]/world/region[ (@name='Spain') ]/*[@type = 'sector' ]/*[@type='subsector']//*[@type='technology')]// CO2/emissions/node() In Function: 1765368225619 java.lang.ArrayIndexOutOfBoundsException: 8 at ModelInterface.ModelGUI2.xmldb.RunMIQuery.buildTable(RunMIQuery.java:188) ... Stopped at ...: java.lang.ArrayIndexOutOfBoundsException: 8 Rows: 0 Columns: 0

while, for instance running:

rgcam::runQuery(conn, co2_query, scenario, "USA")

works well.


@pralitp, do you have any idea why this query:

works correctly in MI, but fails when executed through rgcam, specifically for GCAM-Europe regions?

We though it could be related to:

  • differences in sector hierarchy introduced by the EU grid disaggregation?

  • an XPath expression that MI tolerates but rgcam/BaseX does not?

  • assumptions in RunMIQuery.buildTable() that break with deeper or duplicated structures?

Any guidance would be very helpful! Thank you in advance!!

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