--- policy: /ce/ca/azure/monitor/diagnostic-setting-for-subscription-activity-logs logic: /ce/ca/azure/monitor/diagnostic-setting-for-subscription-activity-logs/prod.logic.yaml executionTime: 2026-05-02T12:04:58.017809491Z generationMs: 57 executionMs: 2997 rows: - id: sub-001 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 199 actual: 199 conditionText: expected: CA10__Azure_Diagnostic_Settings__r.has(COMPLIANT) actual: CA10__Azure_Diagnostic_Settings__r.has(COMPLIANT) runtimeError: {} - id: sub-002 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 200 actual: 200 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: sub-003 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 200 actual: 200 conditionText: expected: otherwise actual: otherwise runtimeError: {} - id: sub-004 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 200 actual: 200 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/azure/monitor/diagnostic-setting-for-subscription-activity-logs/policy.yaml md5Hash: AE1B577BD89B9A60964C0C43130EB2EF content: | --- names: full: Azure Diagnostic Setting exists for Subscription Activity Logs contextual: Diagnostic Setting exists for Subscription Activity Logs description: Enable Diagnostic settings for exporting activity logs. Diagnostic settings are available for each individual resource within a subscription. Settings should be configured for all appropriate resources for your environment. type: COMPLIANCE_POLICY categories: - SECURITY frameworkMappings: - "/frameworks/cis-azure-v6.0.0/06/01/01/01" - "/frameworks/cloudaware/logging-and-monitoring/logging-and-monitoring-configuration" - path: /ce/ca/azure/monitor/diagnostic-setting-for-subscription-activity-logs/prod.logic.yaml md5Hash: 96B8BE0AC111AAFEFC8D00B4E1CC1072 content: | --- inputType: "CA10__CaAzureAccount__c" testData: - file: "test-data.json" conditions: - status: "COMPLIANT" currentStateMessage: "Subscription activity logs have a diagnostic setting with a configured destination." check: RELATED_LIST_HAS: status: "COMPLIANT" relationshipName: "CA10__Azure_Diagnostic_Settings__r" otherwise: status: "INCOMPLIANT" currentStateMessage: "Subscription activity logs do not have a diagnostic setting with a configured destination." remediationMessage: "Create a subscription activity log diagnostic setting and configure a log destination." relatedLists: - relationshipName: "CA10__Azure_Diagnostic_Settings__r" recordTypes: - "caDiagnosticSettingOnAzureSubscription" importExtracts: - file: "/types/CA10__CaAzureDiagnosticSetting__c/object.extracts.yaml" conditions: - status: "INCOMPLIANT" currentStateMessage: "The subscription diagnostic setting does not have a log destination." remediationMessage: "Configure a Log Analytics workspace, storage account, or event hub destination." check: AND: args: - IS_EMPTY: arg: EXTRACT: "CA10__workspaceId__c" - IS_EMPTY: arg: EXTRACT: "CA10__storageAccountId__c" - IS_EMPTY: arg: EXTRACT: "CA10__eventHubAuthorizationRuleId__c" otherwise: status: "COMPLIANT" currentStateMessage: "This subscription diagnostic setting has a configured destination." - path: /ce/ca/azure/monitor/diagnostic-setting-for-subscription-activity-logs/test-data.json md5Hash: B91E2B73DFE3DCA3246F74EDA8266F3E content: | [ { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "199", "conditionText": "CA10__Azure_Diagnostic_Settings__r.has(COMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2026-04-27T00:00:00Z" }, "Id": "sub-001", "CA10__disappearanceTime__c": null, "CA10__Azure_Diagnostic_Settings__r": [ { "Id": "diag-001", "RecordTypeId": "rt-subscription", "CA10__disappearanceTime__c": null, "CA10__subscription__c": "sub-001", "CA10__logsJson__c": "[]", "CA10__workspaceId__c": "/subscriptions/sub-001/resourceGroups/rg/providers/Microsoft.OperationalInsights/workspaces/workspace", "CA10__storageAccountId__c": "", "CA10__eventHubAuthorizationRuleId__c": "", "RecordType": { "DeveloperName": "caDiagnosticSettingOnAzureSubscription", "Id": "rt-subscription" } } ] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "200", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2026-04-27T00:00:00Z" }, "Id": "sub-002", "CA10__disappearanceTime__c": null, "CA10__Azure_Diagnostic_Settings__r": [ { "Id": "diag-002", "RecordTypeId": "rt-subscription", "CA10__disappearanceTime__c": null, "CA10__subscription__c": "sub-002", "CA10__logsJson__c": "[]", "CA10__workspaceId__c": "", "CA10__storageAccountId__c": "", "CA10__eventHubAuthorizationRuleId__c": "", "RecordType": { "DeveloperName": "caDiagnosticSettingOnAzureSubscription", "Id": "rt-subscription" } } ] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "200", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2026-04-27T00:00:00Z" }, "Id": "sub-003", "CA10__disappearanceTime__c": null, "CA10__Azure_Diagnostic_Settings__r": [ { "Id": "diag-003", "RecordTypeId": "rt-resource", "CA10__disappearanceTime__c": null, "CA10__subscription__c": "sub-003", "CA10__logsJson__c": "[]", "CA10__workspaceId__c": "/subscriptions/sub-003/resourceGroups/rg/providers/Microsoft.OperationalInsights/workspaces/workspace", "CA10__storageAccountId__c": "", "CA10__eventHubAuthorizationRuleId__c": "", "RecordType": { "DeveloperName": "caDiagnosticSettingOnAzureResource", "Id": "rt-resource" } } ] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "200", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2026-04-27T00:00:00Z" }, "Id": "sub-004", "CA10__disappearanceTime__c": null, "CA10__Azure_Diagnostic_Settings__r": [] } ] - path: /types/CA10__CaAzureDiagnosticSetting__c/object.extracts.yaml md5Hash: 4AADFEBE59E43127A2529B2F0DB31297 content: "---\nextracts:\n# Not Nullable. Can't have no access, retrieved via\ \ Microsoft.Insights/diagnosticSettings/read\n - name: \"CA10__logsJson__c\"\ \n value: \n FIELD:\n path: \"CA10__logsJson__c\"\n returnType:\ \ BYTES\n undeterminedIf:\n isEmpty: \"Corrupted Data. Diagnostic\ \ Setting Logs JSON cannot be empty.\"\n - name: \"caJsonFrom__logsJson__c\"\ \n value: \n JSON_FROM:\n arg: \n EXTRACT: \"CA10__logsJson__c\"\ \n undeterminedIf:\n isInvalid: \"Logs JSON is invalid.\"\n\ # Nullable. Azure Log Analytics workspace\n - name: \"CA10__workspaceId__c\"\ \n value: \n FIELD:\n path: \"CA10__workspaceId__c\"\n# Nullable.\ \ Azure Storage Account\n - name: \"CA10__storageAccountId__c\"\n value:\ \ \n FIELD:\n path: \"CA10__storageAccountId__c\"\n# Nullable. Azure\ \ Event Hubs\n - name: \"CA10__eventHubAuthorizationRuleId__c\"\n value:\ \ \n FIELD:\n path: \"CA10__eventHubAuthorizationRuleId__c\"\n" script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "sub-001", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "199", "conditionText" : "CA10__Azure_Diagnostic_Settings__r.has(COMPLIANT)", "runtimeError" : null } }, { "Id" : "sub-002", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "200", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "sub-003", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "200", "conditionText" : "otherwise", "runtimeError" : null } }, { "Id" : "sub-004", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "200", "conditionText" : "otherwise", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAzureAccount__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2026-04-27T00:00:00Z") }, "Id" : "sub-001" }, { "context" : { "snapshotTime" : new Date("2026-04-27T00:00:00Z") }, "Id" : "sub-002" }, { "context" : { "snapshotTime" : new Date("2026-04-27T00:00:00Z") }, "Id" : "sub-003" }, { "context" : { "snapshotTime" : new Date("2026-04-27T00:00:00Z") }, "Id" : "sub-004" } ]; """; CREATE TEMP FUNCTION mock_CA10__CaAzureDiagnosticSetting__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2026-04-27T00:00:00Z") }, "CA10__workspaceId__c" : "/subscriptions/sub-001/resourceGroups/rg/providers/Microsoft.OperationalInsights/workspaces/workspace", "CA10__storageAccountId__c" : "", "CA10__eventHubAuthorizationRuleId__c" : "", "CA10__subscription__c" : "sub-001", "Id" : "diag-001", "RecordTypeId" : "rt-subscription" }, { "context" : { "snapshotTime" : new Date("2026-04-27T00:00:00Z") }, "CA10__workspaceId__c" : "", "CA10__storageAccountId__c" : "", "CA10__eventHubAuthorizationRuleId__c" : "", "CA10__subscription__c" : "sub-002", "Id" : "diag-002", "RecordTypeId" : "rt-subscription" }, { "context" : { "snapshotTime" : new Date("2026-04-27T00:00:00Z") }, "CA10__workspaceId__c" : "/subscriptions/sub-003/resourceGroups/rg/providers/Microsoft.OperationalInsights/workspaces/workspace", "CA10__storageAccountId__c" : "", "CA10__eventHubAuthorizationRuleId__c" : "", "CA10__subscription__c" : "sub-003", "Id" : "diag-003", "RecordTypeId" : "rt-resource" } ]; """; CREATE TEMP FUNCTION mock_RecordType() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2026-04-27T00:00:00Z") }, "DeveloperName" : "caDiagnosticSettingOnAzureSubscription", "Id" : "rt-subscription" }, { "context" : { "snapshotTime" : new Date("2026-04-27T00:00:00Z") }, "DeveloperName" : "caDiagnosticSettingOnAzureResource", "Id" : "rt-resource" } ]; """; CREATE TEMP FUNCTION process_CA10__CaAzureAccount__c( obj STRUCT< Id STRING, CA10__Azure_Diagnostic_Settings__r ARRAY, result STRUCT >> >, 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_CA10__Azure_Diagnostic_Settings__r_COMPLIANT2 = 0; if (obj.CA10__Azure_Diagnostic_Settings__r != null) { for (var i3 = 0; i3 < obj.CA10__Azure_Diagnostic_Settings__r.length; i3++) { if (typeof(obj.CA10__Azure_Diagnostic_Settings__r[i3].status) !== 'undefined') { if (obj.CA10__Azure_Diagnostic_Settings__r[i3].status == 'COMPLIANT') { count_CA10__Azure_Diagnostic_Settings__r_COMPLIANT2 += obj.CA10__Azure_Diagnostic_Settings__r[i3].count; } } else { if (obj.CA10__Azure_Diagnostic_Settings__r[i3].result.status == 'COMPLIANT') { count_CA10__Azure_Diagnostic_Settings__r_COMPLIANT2 += 1; } } } } // condition[1], conditionIndex:[100..199] references1.push('Related list [CA10__Azure_Diagnostic_Settings__r] ' + (count_CA10__Azure_Diagnostic_Settings__r_COMPLIANT2 > 0 ? 'has' : 'does not have') + ' objects in COMPLIANT status'); if (count_CA10__Azure_Diagnostic_Settings__r_COMPLIANT2 > 0) { return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "CA10__Azure_Diagnostic_Settings__r.has(COMPLIANT)", currentStateMessage: "Subscription activity logs have a diagnostic setting with a configured destination.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } return {status: 'INCOMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "Subscription activity logs do not have a diagnostic setting with a configured destination.", currentStateReferences: references1.join('\n'), remediation: "Create a subscription activity log diagnostic setting and configure a log destination.", runtimeError: null}; """; CREATE TEMP FUNCTION process_CA10__Azure_Diagnostic_Settings__r( obj STRUCT< CA10__disappearanceTime__c TIMESTAMP, CA10__workspaceId__c STRING, CA10__storageAccountId__c STRING, CA10__eventHubAuthorizationRuleId__c STRING, CA10__subscription__c STRING, Id STRING, RecordTypeId STRING, RecordType STRUCT< DeveloperName 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 Azure [CA10__disappearanceTime__c]: ' + obj.CA10__disappearanceTime__c); if (obj.CA10__disappearanceTime__c != null) { return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[1], conditionIndex:[100..199] references1.push('Record Type Name [obj.RecordType.DeveloperName]: ' + obj.RecordType.DeveloperName); if (!CollectionLib.contains(CollectionLib.fromArray(['caDiagnosticSettingOnAzureSubscription'], true, true, true, true), obj.RecordType.DeveloperName, true)) { return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "not(setOfText(['caDiagnosticSettingOnAzureSubscription']).contains(RecordType.DeveloperName))", currentStateMessage: "Object record type is not applicable", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[2], conditionIndex:[200..299] function extract4() { if (!this.out) { this.out = obj.CA10__workspaceId__c; } return this.out; }; function extract7() { if (!this.out) { this.out = obj.CA10__storageAccountId__c; } return this.out; }; function extract10() { if (!this.out) { this.out = obj.CA10__eventHubAuthorizationRuleId__c; } return this.out; }; references1.push('Workspace ID [obj.CA10__workspaceId__c]: ' + obj.CA10__workspaceId__c); references1.push('Storage Account ID [obj.CA10__storageAccountId__c]: ' + obj.CA10__storageAccountId__c); references1.push('Event Hub Authorizartion Rule ID [obj.CA10__eventHubAuthorizationRuleId__c]: ' + obj.CA10__eventHubAuthorizationRuleId__c); if (TextLib.isEmpty(extract4.call(extract4)) && TextLib.isEmpty(extract7.call(extract7)) && TextLib.isEmpty(extract10.call(extract10))) { return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__workspaceId__c').isEmpty() && extract('CA10__storageAccountId__c').isEmpty() && extract('CA10__eventHubAuthorizationRuleId__c').isEmpty()", currentStateMessage: "The subscription diagnostic setting does not have a log destination.", currentStateReferences: references1.join('\n'), remediation: "Configure a Log Analytics workspace, storage account, or event hub destination.", runtimeError: null}; } return {status: 'COMPLIANT', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "This subscription diagnostic setting has a configured destination.", 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, `CA10__Azure_Diagnostic_Settings__r`.arr AS CA10__Azure_Diagnostic_Settings__r, process_CA10__CaAzureAccount__c( STRUCT( sObject.Id AS Id, `CA10__Azure_Diagnostic_Settings__r`.arr AS CA10__Azure_Diagnostic_Settings__r ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10__CaAzureAccount__c()) AS sObject LEFT JOIN ( SELECT sObject.CA10__subscription__c, ARRAY_AGG( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__workspaceId__c AS CA10__workspaceId__c, sObject.CA10__storageAccountId__c AS CA10__storageAccountId__c, sObject.CA10__eventHubAuthorizationRuleId__c AS CA10__eventHubAuthorizationRuleId__c, sObject.CA10__subscription__c AS CA10__subscription__c, sObject.Id AS Id, sObject.RecordTypeId AS RecordTypeId, STRUCT ( `RecordType`.DeveloperName AS DeveloperName, `RecordType`.Id AS Id ) AS RecordType, process_CA10__Azure_Diagnostic_Settings__r( STRUCT( sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c, sObject.CA10__workspaceId__c AS CA10__workspaceId__c, sObject.CA10__storageAccountId__c AS CA10__storageAccountId__c, sObject.CA10__eventHubAuthorizationRuleId__c AS CA10__eventHubAuthorizationRuleId__c, sObject.CA10__subscription__c AS CA10__subscription__c, sObject.Id AS Id, sObject.RecordTypeId AS RecordTypeId, STRUCT ( `RecordType`.DeveloperName AS DeveloperName, `RecordType`.Id AS Id ) AS RecordType ), sObject.context.snapshotTime ) as result ) ) AS arr FROM UNNEST(mock_CA10__CaAzureDiagnosticSetting__c()) AS sObject LEFT JOIN UNNEST(mock_RecordType()) AS `RecordType` ON sObject.RecordTypeId = `RecordType`.Id GROUP BY sObject.CA10__subscription__c ) AS `CA10__Azure_Diagnostic_Settings__r` ON sObject.Id = `CA10__Azure_Diagnostic_Settings__r`.CA10__subscription__c ) sObject ON sObject.Id = expectedResult.Id;