# QueryResults Constructor confusion

**URL:** <https://forum.inductiveautomation.com/t/queryresults-constructor-confusion/95817>\
**Category:** Ignition\
**Created:** [September 10, 2024, 7:42pm UTC](https://forum.inductiveautomation.com/t/queryresults-constructor-confusion/95817 "2024-09-10T19:42:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathon\_Platt](https://avatars.discourse-cdn.com/v4/letter/j/f19dbf/32.png) [@Jonathon\_Platt](https://forum.inductiveautomation.com/u/Jonathon_Platt)\
**Post date:** [September 10, 2024, 7:42pm UTC](https://forum.inductiveautomation.com/t/queryresults-constructor-confusion/95817/1 "2024-09-10T19:42:40Z")

</div>

Hello!

I'm a bit confused about the following constructor form of QueryResults:  
`QueryResults(Dataset dataset, QueryResults parent, int parentRow)`

What is the purpose of the `parent` and `parentRow` params?

I thought that maybe they were required when using `addNestedQueryResults`, however from my very basic testing It seems like they are not needed (parent) nor used (parentRow) ??

example: In the reporting module I created the following Script data source examples:

`ParentA`: Here I'm passing in the nested child query results in a different order to their constructed `parentRow` param, and looking at the preview the `parentRow` param did not seem to make any affect to the order the nested queries were attached.

`ParentB`: Here I'm not even bothering with specifying a `parent` or `parentRow`, and it doesn't seem to cause any problems either with the preview results.

```python
def updateData(data, sample):
	from system.report import QueryResults
	DataSet = system.dataset.toDataSet
	
	parent_qr_a = QueryResults(DataSet(["Row"],[[0],[1]]))
	child_qr_a_0 = QueryResults(DataSet(["Child_0"],[["value_0"]]), parent_qr_a, 0)
	child_qr_a_1 = QueryResults(DataSet(["Child_1"],[["value_1"]]), parent_qr_a, 1)
	parent_qr_a.addNestedQueryResults("Child",[child_qr_a_1, child_qr_a_0])
	data["ParentA"] = parent_qr_a
	
	parent_qr_b = QueryResults(DataSet(["Row"],[[0],[1]]))
	child_qr_b_0 = QueryResults(DataSet(["Child_0"],[["value_0"]]))
	child_qr_b_1 = QueryResults(DataSet(["Child_1"],[["value_1"]]))
	parent_qr_b.addNestedQueryResults("Child",[child_qr_b_1, child_qr_b_0])
	data["ParentB"] = parent_qr_b

```

Then examined the Preview pane:

```xml
<?xml version="1.0" ?>
<sample-data>
	<!--This is the raw data used to create the report preview.-->
	<ParentA>
		<row-0>
			<Row>0</Row>
			<Child>
				<row-0>
					<Child_1>value_1</Child_1>
				</row-0>
			</Child>
		</row-0>
		<row-1>
			<Row>1</Row>
			<Child>
				<row-0>
					<Child_0>value_0</Child_0>
				</row-0>
			</Child>
		</row-1>
	</ParentA>
	<ParentB>
		<row-0>
			<Row>0</Row>
			<Child>
				<row-0>
					<Child_1>value_1</Child_1>
				</row-0>
			</Child>
		</row-0>
		<row-1>
			<Row>1</Row>
			<Child>
				<row-0>
					<Child_0>value_0</Child_0>
				</row-0>
			</Child>
		</row-1>
	</ParentB>
	<Report>
		<Gateway>SGL-POTG1</Gateway>
		<Name>Report</Name>
		<Path>Report</Path>
		<Timestamp>2024-09-10 14:33:57.733</Timestamp>
	</Report>
</sample-data>

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 10, 2024, 8:23pm UTC](https://forum.inductiveautomation.com/t/queryresults-constructor-confusion/95817/2 "2024-09-10T20:23:52Z")

</div>

The data won't look any different. The parent is only used as a fallback if a query for `rowIndex, columnName` doesn't have anything on the core dataset:

```python
    public Object lookup(int rowIndex, String keyName) {
        ColumnDispatcher column = getColumn(keyName);
        if (column.hasValue(rowIndex)) {
            return column.getValue(rowIndex);
        } else if (parent.isPresent()) {
            return parent.get().lookup(parentRow, keyName);
        } else {
            return null;
        }
    }

```
