--- policy: /ce/ca/oracle/tenancy/resource-in-root-compartment logic: /ce/ca/oracle/tenancy/resource-in-root-compartment/prod.logic.yaml executionTime: 2026-05-02T12:07:27.730333185Z generationMs: 48 executionMs: 1949 rows: - id: test1 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 199 actual: 199 conditionText: expected: CA10O1__Oracle_Resources__r.has(INCOMPLIANT) actual: CA10O1__Oracle_Resources__r.has(INCOMPLIANT) runtimeError: {} - id: test2 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 200 actual: 200 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: test3 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 200 actual: 200 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: test4 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 199 actual: 199 conditionText: expected: CA10O1__Oracle_Resources__r.has(INCOMPLIANT) actual: CA10O1__Oracle_Resources__r.has(INCOMPLIANT) runtimeError: {} - id: test5 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 199 actual: 199 conditionText: expected: CA10O1__Oracle_Resources__r.has(INCOMPLIANT) actual: CA10O1__Oracle_Resources__r.has(INCOMPLIANT) runtimeError: {} - id: test6 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 200 actual: 200 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/oracle/tenancy/resource-in-root-compartment/policy.yaml md5Hash: 287AB43F259B16BFDE67E04C1E27F114 content: | --- names: full: "Oracle Tenancy has CIS-scoped resources created in the root compartment" contextual: "Tenancy has CIS-scoped resources created in the root compartment" description: > CIS-scoped OCI network, compute, database, and storage resources should be created in dedicated compartments instead of the tenancy root compartment to support isolation, delegated administration, least-privilege access control, and clearer tenancy governance. type: "COMPLIANCE_POLICY" categories: - "SECURITY" frameworkMappings: - "/frameworks/cloudaware/identity-and-access-governance/general-access-controls" - "/frameworks/cis-oracle-v3.1.0/06/02" - path: /ce/ca/oracle/tenancy/resource-in-root-compartment/prod.logic.yaml md5Hash: 5E4C18628721AF4ACCAC00500E6B8BA5 content: | --- inputType: "CA10O1__CaOracleTenancy__c" testData: - file: "test-data.json" conditions: - status: "INCOMPLIANT" currentStateMessage: "This tenancy contains CIS-scoped resources in the root compartment." remediationMessage: "Move CIS-scoped resources from the root compartment into dedicated OCI compartments." check: RELATED_LIST_HAS: status: "INCOMPLIANT" relationshipName: "CA10O1__Oracle_Resources__r" otherwise: status: "COMPLIANT" currentStateMessage: "This tenancy does not contain CIS-scoped resources in the root compartment." relatedLists: - relationshipName: "CA10O1__Oracle_Resources__r" importExtracts: - file: "/types/CA10O1__CaOracleResource__c/object.extracts.yaml" conditions: - status: "INAPPLICABLE" currentStateMessage: "This Oracle resource is outside the CIS Oracle scope for this control." check: NOT: arg: CONTAINS: arg: SET: itemType: "TEXT" items: - "Vcn" - "Instance" - "BootVolume" - "Volume" - "FileSystem" - "Bucket" - "AutonomousDatabase" - "Database" - "DbSystem" search: EXTRACT: "CA10O1__resourceType__c" - status: "INCOMPLIANT" currentStateMessage: "This CIS-scoped Oracle resource is created in the root compartment." check: IS_EMPTY: arg: EXTRACT: "CA10O1__compartmentOcid__c" otherwise: status: "COMPLIANT" currentStateMessage: "This CIS-scoped Oracle resource is not created in the root compartment." - path: /ce/ca/oracle/tenancy/resource-in-root-compartment/test-data.json md5Hash: 92F4B1143C7C36227FFB7169FCFA29F9 content: | [ { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "199", "conditionText": "CA10O1__Oracle_Resources__r.has(INCOMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2026-04-12T00:00:00Z" }, "Id": "test1", "CA10O1__disappearanceTime__c": null, "CA10O1__Oracle_Resources__r": [ { "Id": "test1_1", "CA10O1__disappearanceTime__c": null, "CA10O1__tenancy__c": "test1", "CA10O1__resourceType__c": "Instance", "CA10O1__compartmentOcid__c": "", "RecordType": { "Id": "RecordType1", "DeveloperName": "caOracleIaasInstance" } } ] }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "200", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2026-04-12T00:00:00Z" }, "Id": "test2", "CA10O1__disappearanceTime__c": null, "CA10O1__Oracle_Resources__r": [ { "Id": "test2_1", "CA10O1__disappearanceTime__c": null, "CA10O1__tenancy__c": "test2", "CA10O1__resourceType__c": "Instance", "CA10O1__compartmentOcid__c": "ocid1.compartment.oc1..child", "RecordType": { "Id": "RecordType1", "DeveloperName": "caOracleIaasInstance" } } ] }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "200", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2026-04-12T00:00:00Z" }, "Id": "test3", "CA10O1__disappearanceTime__c": null, "CA10O1__Oracle_Resources__r": [ { "Id": "test3_1", "CA10O1__disappearanceTime__c": null, "CA10O1__tenancy__c": "test3", "CA10O1__resourceType__c": "Alarm", "CA10O1__compartmentOcid__c": "ocid1.tenancy.oc1..root", "RecordType": { "Id": "RecordType2", "DeveloperName": "caOracleMonitoringAlarm" } } ] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "199", "conditionText": "CA10O1__Oracle_Resources__r.has(INCOMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2026-04-12T00:00:00Z" }, "Id": "test4", "CA10O1__disappearanceTime__c": null, "CA10O1__Oracle_Resources__r": [ { "Id": "test4_1", "CA10O1__disappearanceTime__c": null, "CA10O1__tenancy__c": "test4", "CA10O1__resourceType__c": "Volume", "CA10O1__compartmentOcid__c": "", "RecordType": { "Id": "RecordType3", "DeveloperName": "caOracleIaasBlockVolume" } } ] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "199", "conditionText": "CA10O1__Oracle_Resources__r.has(INCOMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2026-04-12T00:00:00Z" }, "Id": "test5", "CA10O1__disappearanceTime__c": null, "CA10O1__Oracle_Resources__r": [ { "Id": "test5_1", "CA10O1__disappearanceTime__c": null, "CA10O1__tenancy__c": "test5", "CA10O1__resourceType__c": "BootVolume", "CA10O1__compartmentOcid__c": "", "RecordType": { "Id": "RecordType4", "DeveloperName": "caOracleIaasBootVolume" } } ] }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "200", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2026-04-12T00:00:00Z" }, "Id": "test6", "CA10O1__disappearanceTime__c": null, "CA10O1__Oracle_Resources__r": [ { "Id": "test6_1", "CA10O1__disappearanceTime__c": null, "CA10O1__tenancy__c": "test6", "CA10O1__resourceType__c": "VolumeAttachment", "CA10O1__compartmentOcid__c": "ocid1.tenancy.oc1..root", "RecordType": { "Id": "RecordType5", "DeveloperName": "caOracleIaasVolumeAttachment" } } ] } ] - path: /types/CA10O1__CaOracleResource__c/object.extracts.yaml md5Hash: 6F970DC267C15B0B636DD4AA7DE25172 content: | --- extracts: - name: "Name" value: FIELD: path: "Name" - name: "CA10O1__resourceType__c" value: FIELD: path: "CA10O1__resourceType__c" - name: "CA10O1__compartmentOcid__c" value: FIELD: path: "CA10O1__compartmentOcid__c" script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "test1", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "199", "conditionText" : "CA10O1__Oracle_Resources__r.has(INCOMPLIANT)", "runtimeError" : null } }, { "Id" : "test2", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "200", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "test3", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "200", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "test4", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "199", "conditionText" : "CA10O1__Oracle_Resources__r.has(INCOMPLIANT)", "runtimeError" : null } }, { "Id" : "test5", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "199", "conditionText" : "CA10O1__Oracle_Resources__r.has(INCOMPLIANT)", "runtimeError" : null } }, { "Id" : "test6", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "200", "conditionText" : "otherwise", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10O1__CaOracleTenancy__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "Id" : "test1" }, { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "Id" : "test2" }, { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "Id" : "test3" }, { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "Id" : "test4" }, { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "Id" : "test5" }, { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "Id" : "test6" } ]; """; CREATE TEMP FUNCTION mock_CA10O1__CaOracleResource__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "CA10O1__resourceType__c" : "Instance", "CA10O1__compartmentOcid__c" : "", "CA10O1__tenancy__c" : "test1", "Id" : "test1_1" }, { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "CA10O1__resourceType__c" : "Instance", "CA10O1__compartmentOcid__c" : "ocid1.compartment.oc1..child", "CA10O1__tenancy__c" : "test2", "Id" : "test2_1" }, { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "CA10O1__resourceType__c" : "Alarm", "CA10O1__compartmentOcid__c" : "ocid1.tenancy.oc1..root", "CA10O1__tenancy__c" : "test3", "Id" : "test3_1" }, { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "CA10O1__resourceType__c" : "Volume", "CA10O1__compartmentOcid__c" : "", "CA10O1__tenancy__c" : "test4", "Id" : "test4_1" }, { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "CA10O1__resourceType__c" : "BootVolume", "CA10O1__compartmentOcid__c" : "", "CA10O1__tenancy__c" : "test5", "Id" : "test5_1" }, { "context" : { "snapshotTime" : new Date("2026-04-12T00:00:00Z") }, "CA10O1__resourceType__c" : "VolumeAttachment", "CA10O1__compartmentOcid__c" : "ocid1.tenancy.oc1..root", "CA10O1__tenancy__c" : "test6", "Id" : "test6_1" } ]; """; CREATE TEMP FUNCTION process_CA10O1__CaOracleTenancy__c( obj STRUCT< Id STRING, CA10O1__Oracle_Resources__r ARRAY >> >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" var references1 = []; // condition[0], conditionIndex:[0..99] if (false) { return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared()", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } var count_CA10O1__Oracle_Resources__r_INCOMPLIANT2 = 0; if (obj.CA10O1__Oracle_Resources__r != null) { for (var i3 = 0; i3 < obj.CA10O1__Oracle_Resources__r.length; i3++) { if (typeof(obj.CA10O1__Oracle_Resources__r[i3].status) !== 'undefined') { if (obj.CA10O1__Oracle_Resources__r[i3].status == 'INCOMPLIANT') { count_CA10O1__Oracle_Resources__r_INCOMPLIANT2 += obj.CA10O1__Oracle_Resources__r[i3].count; } } else { if (obj.CA10O1__Oracle_Resources__r[i3].result.status == 'INCOMPLIANT') { count_CA10O1__Oracle_Resources__r_INCOMPLIANT2 += 1; } } } } // condition[1], conditionIndex:[100..199] references1.push('Related list [CA10O1__Oracle_Resources__r] ' + (count_CA10O1__Oracle_Resources__r_INCOMPLIANT2 > 0 ? 'has' : 'does not have') + ' objects in INCOMPLIANT status'); if (count_CA10O1__Oracle_Resources__r_INCOMPLIANT2 > 0) { return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "CA10O1__Oracle_Resources__r.has(INCOMPLIANT)", currentStateMessage: "This tenancy contains CIS-scoped resources in the root compartment.", currentStateReferences: references1.join('\n'), remediation: "Move CIS-scoped resources from the root compartment into dedicated OCI compartments.", runtimeError: null}; } return {status: 'COMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "This tenancy does not contain CIS-scoped resources in the root compartment.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; """; CREATE TEMP FUNCTION process_CA10O1__Oracle_Resources__r( obj STRUCT< CA10O1__disappearanceTime__c TIMESTAMP, CA10O1__resourceType__c STRING, CA10O1__compartmentOcid__c STRING, CA10O1__tenancy__c STRING, Id STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" var TextLib = new function () { this.normalize = function(arg) { return arg == null ? '' : arg.replace(/\s+/g, ' ').trim().toLowerCase(); }; this.isEmpty = function(arg) { return this.normalize(arg) == ''; }; this.isNotEmpty = function(arg) { return this.normalize(arg) != ''; }; this.equal = function(left, right) { return this.normalize(left) == this.normalize(right); }; this.notEqual = function(left, right) { return this.normalize(left) != this.normalize(right); }; this.startsWith = function(arg, substring) { return this.normalize(arg).startsWith(this.normalize(substring)); }; this.endsWith = function(arg, substring) { return this.normalize(arg).endsWith(this.normalize(substring)); }; this.contains = function(arg, substring) { return this.normalize(arg).includes(this.normalize(substring)); }; this.containsAll = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.every(sub => normalizedArg.includes(this.normalize(sub))); }; this.containsAny = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.some(sub => normalizedArg.includes(this.normalize(sub))); }; }(); var CollectionLib = new function () { this.parse = function(arg, separator, skipEmpty, skipDuplicates, sort, normalize) { if (arg == null) return []; let parts = arg.split(separator); return this.fromArray(parts, skipEmpty, skipDuplicates, sort, normalize); }; this.fromArray = function(arr, skipEmpty, skipDuplicates, sort, normalize) { if (arr == null) return []; let result = []; let seen = new Set(); arr.forEach(el => { let normalized = normalize ? TextLib.normalize(el) : BytesLib.normalize(el); if (!skipEmpty || (normalize ? TextLib.isNotEmpty(el) : BytesLib.isNotEmpty(el))) { if (!skipDuplicates || !seen.has(normalized)) { if (skipDuplicates) seen.add(normalized); result.push(normalized); } } }); if (sort) result.sort(); return result; }; this.equal = function(left, right) { left = left == null ? [] : left; right = right == null ? [] : right; if (left.length !== right.length) return false; for (let i = 0; i < left.length; i++) { if (left[i] !== right[i]) return false; } return true; }; this.notEqual = function(left, right) { return !this.equal(left, right); }; this.size = function(collection) { return collection == null ? 0 : collection.length; }; this.startsWith = function(collection, search, normalize) { if (collection == null || collection.length === 0) return false; let normalizedSearch = normalize ? TextLib.normalize(search) : BytesLib.normalize(search); return collection[0] === normalizedSearch; }; this.endsWith = function(collection, search, normalize) { if (collection == null || collection.length === 0) return false; let normalizedSearch = normalize ? TextLib.normalize(search) : BytesLib.normalize(search); return collection[collection.length - 1] === normalizedSearch; }; this.contains = function(collection, search, normalize) { if (collection == null || collection.length === 0) return false; return collection.includes(normalize ? TextLib.normalize(search) : BytesLib.normalize(search)); }; this.containsAll = function(collection, searchArray, normalize) { if (collection == null || collection.length === 0 || searchArray == null || searchArray.length === 0) return false; return searchArray.every(search => collection.includes(normalize ? TextLib.normalize(search) : BytesLib.normalize(search))); }; this.containsAny = function(collection, searchArray, normalize) { if (collection == null || collection.length === 0 || searchArray == null || searchArray.length === 0) return false; return searchArray.some(search => collection.includes(normalize ? TextLib.normalize(search) : BytesLib.normalize(search))); }; }(); var BytesLib = new function () { this.normalize = function(arg) { return arg == null ? '' : arg; }; this.isEmpty = function(arg) { return this.normalize(arg) == ''; }; this.isNotEmpty = function(arg) { return this.normalize(arg) != ''; }; this.equal = function(left, right) { return this.normalize(left) == this.normalize(right); }; this.notEqual = function(left, right) { return this.normalize(left) != this.normalize(right); }; this.startsWith = function(arg, substring) { return this.normalize(arg).startsWith(this.normalize(substring)); }; this.endsWith = function(arg, substring) { return this.normalize(arg).endsWith(this.normalize(substring)); }; this.contains = function(arg, substring) { return this.normalize(arg).includes(this.normalize(substring)); }; this.containsAll = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.every(sub => normalizedArg.includes(this.normalize(sub))); }; this.containsAny = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.some(sub => normalizedArg.includes(this.normalize(sub))); }; }(); var references1 = []; // condition[0], conditionIndex:[0..99] references1.push('Deleted From Oracle [CA10O1__disappearanceTime__c]: ' + obj.CA10O1__disappearanceTime__c); if (obj.CA10O1__disappearanceTime__c != null) { return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10O1__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[1], conditionIndex:[100..199] function extract3() { if (!this.out) { this.out = obj.CA10O1__resourceType__c; } return this.out; }; references1.push('Resource Type [obj.CA10O1__resourceType__c]: ' + obj.CA10O1__resourceType__c); if (!CollectionLib.contains(CollectionLib.fromArray(['Vcn', 'Instance', 'BootVolume', 'Volume', 'FileSystem', 'Bucket', 'AutonomousDatabase', 'Database', 'DbSystem'], true, true, true, true), extract3.call(extract3), true)) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "not(setOfText(['Vcn', 'Instance', 'BootVolume', 'Volume', 'FileSystem', 'Bucket', 'AutonomousDatabase', 'Database', 'DbSystem']).contains(extract('CA10O1__resourceType__c')))", currentStateMessage: "This Oracle resource is outside the CIS Oracle scope for this control.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[2], conditionIndex:[200..299] function extract6() { if (!this.out) { this.out = obj.CA10O1__compartmentOcid__c; } return this.out; }; references1.push('Compartment OCID [obj.CA10O1__compartmentOcid__c]: ' + obj.CA10O1__compartmentOcid__c); if (TextLib.isEmpty(extract6.call(extract6))) { return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10O1__compartmentOcid__c').isEmpty()", currentStateMessage: "This CIS-scoped Oracle resource is created in the root compartment.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } return {status: 'COMPLIANT', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "This CIS-scoped Oracle resource is not created in the root compartment.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; """; SELECT expectedResult.Id as Id, IF ( IFNULL(expectedResult.expectedResult.status, '') = IFNULL(sObject.result.status, '') AND IFNULL(expectedResult.expectedResult.conditionIndex, -1) = IFNULL(sObject.result.conditionIndex, -1) AND IFNULL(expectedResult.expectedResult.conditionText, '') = IFNULL(sObject.result.conditionText, '') AND IFNULL(expectedResult.expectedResult.runtimeError, '') = IFNULL(sObject.result.runtimeError, ''), "MATCH", "FAIL" ) as match, expectedResult.expectedResult.status as expectedStatus, sObject.result.status as actualStatus, expectedResult.expectedResult.conditionIndex as expectedConditionIndex, sObject.result.conditionIndex as actualConditionIndex, expectedResult.expectedResult.conditionText as expectedConditionText, sObject.result.conditionText as actualConditionText, expectedResult.expectedResult.runtimeError as expectedRuntimeError, sObject.result.runtimeError as actualRuntimeError FROM UNNEST(mock_ExpectedResult()) expectedResult LEFT JOIN ( SELECT sObject.Id AS Id, `CA10O1__Oracle_Resources__r`.arr AS CA10O1__Oracle_Resources__r, process_CA10O1__CaOracleTenancy__c( STRUCT( sObject.Id AS Id, `CA10O1__Oracle_Resources__r`.arr AS CA10O1__Oracle_Resources__r ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10O1__CaOracleTenancy__c()) AS sObject LEFT JOIN ( SELECT sObject.CA10O1__tenancy__c, ARRAY_AGG( STRUCT( sObject.CA10O1__disappearanceTime__c AS CA10O1__disappearanceTime__c, sObject.CA10O1__resourceType__c AS CA10O1__resourceType__c, sObject.CA10O1__compartmentOcid__c AS CA10O1__compartmentOcid__c, sObject.CA10O1__tenancy__c AS CA10O1__tenancy__c, sObject.Id AS Id, process_CA10O1__Oracle_Resources__r( STRUCT( sObject.CA10O1__disappearanceTime__c AS CA10O1__disappearanceTime__c, sObject.CA10O1__resourceType__c AS CA10O1__resourceType__c, sObject.CA10O1__compartmentOcid__c AS CA10O1__compartmentOcid__c, sObject.CA10O1__tenancy__c AS CA10O1__tenancy__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result ) ) AS arr FROM UNNEST(mock_CA10O1__CaOracleResource__c()) AS sObject GROUP BY sObject.CA10O1__tenancy__c ) AS `CA10O1__Oracle_Resources__r` ON sObject.Id = `CA10O1__Oracle_Resources__r`.CA10O1__tenancy__c ) sObject ON sObject.Id = expectedResult.Id;