---
policy: /ce/ca/aws/guardduty/detector-not-enabled-in-all-regions
logic: /ce/ca/aws/guardduty/detector-not-enabled-in-all-regions/prod.logic.yaml
executionTime: 2025-10-08T17:39:18.226071363Z
generationMs: 67
executionMs: 854
rows:
  - id: test1
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: CA10__AWS_GuardDuty_Detectors__r.count(COMPLIANT) == CA10__AWS_Account_Regions__r.count(COMPLIANT)
      actual: CA10__AWS_GuardDuty_Detectors__r.count(COMPLIANT) == CA10__AWS_Account_Regions__r.count(COMPLIANT)
    runtimeError: {}
  - id: test2
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/guardduty/detector-not-enabled-in-all-regions/policy.yaml
    md5Hash: 43F4FB3E47F9AED2382F4E269EE0A477
    content: "---\nnames:\n  full: \"AWS GuardDuty is not enabled in all regions\"\
      \n  contextual: \"GuardDuty is not enabled in all regions\"\ndescription: >\n\
      \  Amazon GuardDuty is a threat detection service that continuously monitors\
      \ for \n  malicious activity and unauthorized behavior to protect your AWS accounts\
      \ and \n  workloads. It is recommended that GuardDuty be enabled in all supported\
      \ AWS regions \n  to ensure comprehensive threat coverage.\ntype: \"COMPLIANCE_POLICY\"\
      \ncategories:\n  - \"SECURITY\"\nframeworkMappings:\n  - \"/frameworks/cloudaware/resource-security/threat-protection\"\
      \n  - \"/frameworks/aws-well-architected/security/detection/bp03\"\n  - \"/frameworks/aws-well-architected/security/detection/bp04\"\
      \n  - \"/frameworks/aws-well-architected/security/infrastructure-protection/sec05/bp03\"\
      \n  - \"/frameworks/aws-well-architected/security/infrastructure-protection/sec05/bp04\"\
      \n  - \"/frameworks/aws-fsbp-v1.0.0/guardduty/01\"\nsimilarPolicies:\n  awsSecurityHub:\n\
      \    - name: \"[GuardDuty.1] GuardDuty should be enabled\"\n      url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/guardduty-controls.html#guardduty-1\""
  - path: /ce/ca/aws/guardduty/detector-not-enabled-in-all-regions/prod.logic.yaml
    md5Hash: 494F8261BAC4B1449F97D20FCA47B454
    content: |-
      ---
      inputType: "CA10__CaAwsAccount__c"
      testData:
       - file: "test-data.json"
      conditions:
        - status: "COMPLIANT"
          currentStateMessage: "GuardDuty is enabled for all active regions."
          check:
            IS_EQUAL:
              left:
                RELATED_LIST_COUNT:
                  status: "COMPLIANT"
                  relationshipName: "CA10__AWS_GuardDuty_Detectors__r"
              right:
                RELATED_LIST_COUNT:
                  status: "COMPLIANT"
                  relationshipName: "CA10__AWS_Account_Regions__r"
      otherwise:
        status: "INCOMPLIANT"
        currentStateMessage: "GuardDuty is not enabled for all active regions."
        remediationMessage: "Consider enabling GuardDuty in each active region to ensure full threat detection coverage."
      relatedLists:
        - relationshipName: "CA10__AWS_GuardDuty_Detectors__r"
          importExtracts:
            - file: /types/CA10__CaAwsGuardDutyDetector__c/object.extracts.yaml
          conditions:
            - status: "COMPLIANT"
              currentStateMessage: "Active AWS GuardDuty Detector."
              check:
                IS_EQUAL:
                  left:
                    EXTRACT: "CA10__status__c"
                  right:
                    TEXT: "ENABLED"
          otherwise:
            status: "INAPPLICABLE"
            currentStateMessage: "This GuardDuty detector is not active."
        - relationshipName: "CA10__AWS_Account_Regions__r"
          importExtracts:
            - file: /types/CA10__CaAwsAccountRegion__c/object.extracts.yaml
          conditions:
          - status: "COMPLIANT"
            currentStateMessage: "Active AWS Account Region."
            check:
              NOT_EQUAL:
                left:
                  EXTRACT: "CA10__status__c"
                right:
                  TEXT: "not-opted-in"
          otherwise:
            status: "INAPPLICABLE"
            currentStateMessage: "This AWS Account Region is not active."
  - path: /ce/ca/aws/guardduty/detector-not-enabled-in-all-regions/test-data.json
    md5Hash: 5D71D7D67F6EBA69009EBC0864D0E188
    content: |-
      [
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "CA10__AWS_GuardDuty_Detectors__r.count(COMPLIANT) == CA10__AWS_Account_Regions__r.count(COMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-10-08T06:14:51Z"
              },
              "Id": "test1",
              "CA10__AWS_GuardDuty_Detectors__r": [
                  {
                      "CA10__disappearanceTime__c": null,
                      "CA10__status__c": "ENABLED",
                      "CA10__account__c": "test1",
                      "Id": "test1_1"
                  },
                  {
                      "CA10__disappearanceTime__c": null,
                      "CA10__status__c": "ENABLED",
                      "CA10__account__c": "test1",
                      "Id": "test1_2"
                  }
              ],
              "CA10__AWS_Account_Regions__r": [
                  {
                      "CA10__status__c": "opt-in",
                      "CA10__account__c": "test1",
                      "Id": "test1_3"
                  },
                  {
                      "CA10__status__c": "opt-in",
                      "CA10__account__c": "test1",
                      "Id": "test1_4"
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "200",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-10-08T06:14:51Z"
              },
              "Id": "test2",
              "CA10__AWS_GuardDuty_Detectors__r": [
                  {
                      "CA10__disappearanceTime__c": null,
                      "CA10__status__c": "ENABLED",
                      "CA10__account__c": "test2",
                      "Id": "test2_1"
                  }
              ],
              "CA10__AWS_Account_Regions__r": [
                  {
                      "CA10__status__c": "opted-in",
                      "CA10__account__c": "test2",
                      "Id": "test2_2"
                  },
                  {
                      "CA10__status__c": "opted-in",
                      "CA10__account__c": "test2",
                      "Id": "test2_3"
                  }
              ]
          }
      ]
  - path: /types/CA10__CaAwsAccountRegion__c/object.extracts.yaml
    md5Hash: B5D54D4844B8E77238E14E730ABEE3C4
    content: "---\nextracts:\n  - name: CA10__status__c\n    value: \n      FIELD:\n\
      \        path: CA10__status__c\n        undeterminedIf:\n          isEmpty:\
      \ \"Account Region status must be specified \"\n  - name: CA10__ebsStorageEncryption__c\n\
      \    value: \n      FIELD:\n        path: CA10__ebsStorageEncryption__c\n  \
      \      undeterminedIf:\n          isEmpty: \"EBS Storage Encryption can not\
      \ be empty. Possibly corrupted data.\""
  - path: /types/CA10__CaAwsGuardDutyDetector__c/object.extracts.yaml
    md5Hash: B1458F9B9038182B01C83196ED7E48C8
    content: |-
      ---
      extracts:
      # Values: ENABLED | DISABLED. Not Nullable.
        - name: "CA10__status__c"
          value:
            FIELD:
              path: "CA10__status__c"
              undeterminedIf:
                noAccessDelegate:
                  path: "CA10__status__c"
                  currentStateMessage: "The status cannot be empty. Possible permission issue with guardduty:GetDetector."
        - name: "CA10__dataSourcesJson__c"
          value:
            FIELD:
              path: "CA10__dataSourcesJson__c"
              undeterminedIf:
                noAccessDelegate:
                  path: "CA10__dataSourcesJson__c"
                  currentStateMessage: "The Data Sources cannot be empty. Possible permission issue with guardduty:GetDetector."
        - name: "caJsonFrom__dataSourcesJson__c"
          value:
            JSON_FROM:
              arg:
                EXTRACT: "CA10__dataSourcesJson__c"
              undeterminedIf:
                isInvalid: "The Data Sources JSON is invalid."
script: |-
  CREATE TEMP FUNCTION mock_ExpectedResult()
  RETURNS ARRAY<STRUCT<
          Id STRING,
          expectedResult STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, runtimeError STRING>
      >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "Id" : "test1",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "CA10__AWS_GuardDuty_Detectors__r.count(COMPLIANT) == CA10__AWS_Account_Regions__r.count(COMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test2",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsAccount__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-10-08T06:14:51Z")
    },
    "Id" : "test1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-08T06:14:51Z")
    },
    "Id" : "test2"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsGuardDutyDetector__c()
  RETURNS ARRAY<STRUCT<
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__status__c STRING,
      CA10__account__c STRING,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-10-08T06:14:51Z")
    },
    "CA10__status__c" : "ENABLED",
    "CA10__account__c" : "test1",
    "Id" : "test1_1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-08T06:14:51Z")
    },
    "CA10__status__c" : "ENABLED",
    "CA10__account__c" : "test1",
    "Id" : "test1_2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-08T06:14:51Z")
    },
    "CA10__status__c" : "ENABLED",
    "CA10__account__c" : "test2",
    "Id" : "test2_1"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsAccountRegion__c()
  RETURNS ARRAY<STRUCT<
      CA10__status__c STRING,
      CA10__account__c STRING,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-10-08T06:14:51Z")
    },
    "CA10__status__c" : "opt-in",
    "CA10__account__c" : "test1",
    "Id" : "test1_3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-08T06:14:51Z")
    },
    "CA10__status__c" : "opt-in",
    "CA10__account__c" : "test1",
    "Id" : "test1_4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-08T06:14:51Z")
    },
    "CA10__status__c" : "opted-in",
    "CA10__account__c" : "test2",
    "Id" : "test2_2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-08T06:14:51Z")
    },
    "CA10__status__c" : "opted-in",
    "CA10__account__c" : "test2",
    "Id" : "test2_3"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAwsAccount__c(
      obj STRUCT<
          Id STRING,
          CA10__AWS_GuardDuty_Detectors__r ARRAY<STRUCT<
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__status__c STRING,
              CA10__account__c STRING,
              Id STRING,
              result STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
          >>,
          CA10__AWS_Account_Regions__r ARRAY<STRUCT<
              CA10__status__c STRING,
              CA10__account__c STRING,
              Id STRING,
              result STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
          >>
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  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__AWS_GuardDuty_Detectors__r_COMPLIANT2 = 0;
      if (obj.CA10__AWS_GuardDuty_Detectors__r != null) {
          for (var i4 = 0; i4 < obj.CA10__AWS_GuardDuty_Detectors__r.length; i4++) {
              if (obj.CA10__AWS_GuardDuty_Detectors__r[i4].result.status == 'COMPLIANT') {
                  count_CA10__AWS_GuardDuty_Detectors__r_COMPLIANT2 += 1;
              }
          }
      }
      var count_CA10__AWS_Account_Regions__r_COMPLIANT3 = 0;
      if (obj.CA10__AWS_Account_Regions__r != null) {
          for (var i5 = 0; i5 < obj.CA10__AWS_Account_Regions__r.length; i5++) {
              if (obj.CA10__AWS_Account_Regions__r[i5].result.status == 'COMPLIANT') {
                  count_CA10__AWS_Account_Regions__r_COMPLIANT3 += 1;
              }
          }
      }
      // condition[1], conditionIndex:[100..199]
      references1.push('Related list [CA10__AWS_GuardDuty_Detectors__r] has ' + count_CA10__AWS_GuardDuty_Detectors__r_COMPLIANT2 + ' objects in COMPLIANT status');
      references1.push('Related list [CA10__AWS_Account_Regions__r] has ' + count_CA10__AWS_Account_Regions__r_COMPLIANT3 + ' objects in COMPLIANT status');
      if (count_CA10__AWS_GuardDuty_Detectors__r_COMPLIANT2 == count_CA10__AWS_Account_Regions__r_COMPLIANT3) {
          return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "CA10__AWS_GuardDuty_Detectors__r.count(COMPLIANT) == CA10__AWS_Account_Regions__r.count(COMPLIANT)", currentStateMessage: "GuardDuty is enabled for all active regions.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'INCOMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "GuardDuty is not enabled for all active regions.", currentStateReferences: references1.join('\n'), remediation: "Consider enabling GuardDuty in each active region to ensure full threat detection coverage.", runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10__AWS_GuardDuty_Detectors__r(
      obj STRUCT<
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__status__c STRING,
          CA10__account__c STRING,
          Id STRING
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  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 references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From AWS [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]
      function fieldChecked4() {
          if (TextLib.isEmpty(obj.CA10__status__c)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10__status__c.delegatedTo(CA10__status__c).isEmpty()", currentStateMessage: "The status cannot be empty. Possible permission issue with guardduty:GetDetector.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__status__c;
      }
      function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; };
      references1.push('Status [obj.CA10__status__c]: ' + obj.CA10__status__c);
      try {
          if (TextLib.equal(extract3.call(extract3), 'ENABLED')) {
              return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__status__c') == 'ENABLED'", currentStateMessage: "Active AWS GuardDuty Detector.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      return {status: 'INAPPLICABLE', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "This GuardDuty detector is not active.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10__AWS_Account_Regions__r(
      obj STRUCT<
          CA10__status__c STRING,
          CA10__account__c STRING,
          Id STRING
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  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 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};
      }
      // condition[1], conditionIndex:[100..199]
      function fieldChecked4() {
          if (TextLib.isEmpty(obj.CA10__status__c)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10__status__c.delegatedTo(CA10__status__c).isEmpty()", currentStateMessage: "The status cannot be empty. Possible permission issue with guardduty:GetDetector.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__status__c;
      }
      function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; };
      references1.push('Status [obj.CA10__status__c]: ' + obj.CA10__status__c);
      try {
          if (TextLib.notEqual(extract3.call(extract3), 'not-opted-in')) {
              return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__status__c') != 'not-opted-in'", currentStateMessage: "Active AWS Account Region.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      return {status: 'INAPPLICABLE', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "This AWS Account Region is not active.", 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__AWS_GuardDuty_Detectors__r`.arr AS CA10__AWS_GuardDuty_Detectors__r,
          `CA10__AWS_Account_Regions__r`.arr AS CA10__AWS_Account_Regions__r,
          process_CA10__CaAwsAccount__c(
              STRUCT(
                  sObject.Id AS Id,
                  `CA10__AWS_GuardDuty_Detectors__r`.arr AS CA10__AWS_GuardDuty_Detectors__r,
                  `CA10__AWS_Account_Regions__r`.arr AS CA10__AWS_Account_Regions__r
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAwsAccount__c()) AS sObject
      LEFT JOIN (
          SELECT
              sObject.CA10__account__c,
              ARRAY_AGG(
                  STRUCT(
                      sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                      sObject.CA10__status__c AS CA10__status__c,
                      sObject.CA10__account__c AS CA10__account__c,
                      sObject.Id AS Id,
                      process_CA10__AWS_GuardDuty_Detectors__r(
                          STRUCT(
                              sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                              sObject.CA10__status__c AS CA10__status__c,
                              sObject.CA10__account__c AS CA10__account__c,
                              sObject.Id AS Id
                          ),
                          sObject.context.snapshotTime
                      ) as result
                  )
              ) AS arr
          FROM UNNEST(mock_CA10__CaAwsGuardDutyDetector__c()) AS sObject
          GROUP BY sObject.CA10__account__c
      ) AS `CA10__AWS_GuardDuty_Detectors__r`
          ON sObject.Id = `CA10__AWS_GuardDuty_Detectors__r`.CA10__account__c
      LEFT JOIN (
          SELECT
              sObject.CA10__account__c,
              ARRAY_AGG(
                  STRUCT(
                      sObject.CA10__status__c AS CA10__status__c,
                      sObject.CA10__account__c AS CA10__account__c,
                      sObject.Id AS Id,
                      process_CA10__AWS_Account_Regions__r(
                          STRUCT(
                              sObject.CA10__status__c AS CA10__status__c,
                              sObject.CA10__account__c AS CA10__account__c,
                              sObject.Id AS Id
                          ),
                          sObject.context.snapshotTime
                      ) as result
                  )
              ) AS arr
          FROM UNNEST(mock_CA10__CaAwsAccountRegion__c()) AS sObject
          GROUP BY sObject.CA10__account__c
      ) AS `CA10__AWS_Account_Regions__r`
          ON sObject.Id = `CA10__AWS_Account_Regions__r`.CA10__account__c
  ) sObject ON sObject.Id = expectedResult.Id;
