---
policy: /ce/ca/google/storage/bucket-versioning
logic: /ce/ca/google/storage/bucket-versioning/prod.logic.yaml
executionTime: 2025-10-25T12:02:55.468317869Z
generationMs: 74
executionMs: 630
rows:
  - id: '001'
    match: true
    status:
      expected: DISAPPEARED
      actual: DISAPPEARED
    conditionIndex:
      expected: 99
      actual: 99
    conditionText:
      expected: isDisappeared(CA10__disappearanceTime__c)
      actual: isDisappeared(CA10__disappearanceTime__c)
    runtimeError: {}
  - id: '002'
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: CA10G1__Google_Logging_Log_Sinks__r.hasNo(COMPLIANT)
      actual: CA10G1__Google_Logging_Log_Sinks__r.hasNo(COMPLIANT)
    runtimeError: {}
  - id: '003'
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: extract('CA10__retentionPolicyLock__c') == 'Locked'
      actual: extract('CA10__retentionPolicyLock__c') == 'Locked'
    runtimeError: {}
  - id: '004'
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: extract('CA10__versioningEnabled__c') == true
      actual: extract('CA10__versioningEnabled__c') == true
    runtimeError: {}
  - id: '005'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 400
      actual: 400
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/google/storage/bucket-versioning/policy.yaml
    md5Hash: 397748D145CC7E5363D8B89345BDA8C5
    content: "---\nnames: \n  full: \"Google Storage Bucket with Log Sink does not\
      \ have Versioning\"\n  contextual: \"Bucket with Log Sink does not have Versioning\"\
      \ndescription: \"Ensure that Object Versioning is enabled for Google Storage\\\
      \n  \\ buckets configured as destinations for log sinks.\"\ntype: \"COMPLIANCE_POLICY\"\
      \ncategories:\n  - \"SECURITY\"\nframeworkMappings:\n  - \"/frameworks/nist-sp-800-53-r4/au/11\"\
      \n  - \"/frameworks/pci-dss-v3.2.1/10/05\"\n  - \"/frameworks/iso-iec-27001-2013/12/04/02\"\
      \n  - \"/frameworks/iso-iec-27001-2013/18/01/03\"\n  - \"/frameworks/cloudaware/logging-and-monitoring/logging-and-monitoring-configuration\"\
      \n"
  - path: /ce/ca/google/storage/bucket-versioning/prod.logic.yaml
    md5Hash: 35536A3D71A63F8C145742E1A9CD69D1
    content: |-
      ---

      inputType: "CA10__CaGoogleStorageBucket__c"
      testData:
        - file: test-data.json
      importExtracts:
        - file: /types/CA10__CaGoogleStorageBucket__c/object.extracts.yaml
      conditions:
        - status: "INAPPLICABLE"
          currentStateMessage: "The bucket is a log sink destination."
          check:
            RELATED_LIST_HAS_NO:
              status: "COMPLIANT"
              relationshipName: "CA10G1__Google_Logging_Log_Sinks__r"
        - status: "INAPPLICABLE"
          currentStateMessage: "The storage bucket has a locked retention policy."
          check:
            IS_EQUAL:
              left:
                EXTRACT: "CA10__retentionPolicyLock__c"
              right:
                TEXT: "Locked"
        - status: "COMPLIANT"
          currentStateMessage: "Versioning is enabled on this storage bucket."
          check:
            IS_EQUAL:
              left:
                EXTRACT: "CA10__versioningEnabled__c"
              right:
                BOOLEAN: true
      otherwise:
        status: "INCOMPLIANT"
        currentStateMessage: "Versioning is not enabled on this storage bucket."
        remediationMessage: "Enable Versioning on this bucket."
      relatedLists:
        - relationshipName: "CA10G1__Google_Logging_Log_Sinks__r"
          conditions: []
          otherwise:
            status: "COMPLIANT"
            currentStateMessage: "This is a Log Sink with a storage bucket destination."
  - path: /ce/ca/google/storage/bucket-versioning/test-data.json
    md5Hash: EEA534C06A95C9B41650DD759619CB3C
    content: |
      [
        {
          "expectedResult": {
            "status": "DISAPPEARED",
            "conditionIndex": "99",
            "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-10-07T10:39:40Z" },
          "CA10__disappearanceTime__c": "2024-12-16T11:44:48Z",
          "CA10__retentionPolicyLock__c": "",
          "CA10__versioningEnabled__c": false,
          "Id": "001",
          "CA10G1__Google_Logging_Log_Sinks__r": []
        },
        {
          "expectedResult": {
            "status": "INAPPLICABLE",
            "conditionIndex": "199",
            "conditionText": "CA10G1__Google_Logging_Log_Sinks__r.hasNo(COMPLIANT)",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-10-07T10:39:40Z" },
          "CA10__disappearanceTime__c": null,
          "CA10__retentionPolicyLock__c": "",
          "CA10__versioningEnabled__c": false,
          "Id": "002",
          "CA10G1__Google_Logging_Log_Sinks__r": []
        },
        {
          "expectedResult": {
            "status": "INAPPLICABLE",
            "conditionIndex": "299",
            "conditionText": "extract('CA10__retentionPolicyLock__c') == 'Locked'",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-10-07T10:39:40Z" },
          "CA10__disappearanceTime__c": null,
          "CA10__retentionPolicyLock__c": "Locked",
          "CA10__versioningEnabled__c": false,
          "Id": "003",
          "CA10G1__Google_Logging_Log_Sinks__r": [
            {
              "CA10G1__disappearanceTime__c": null,
              "CA10G1__bucket__c": "003",
              "Id": "ls001",
              "RecordTypeId": "0125f0000003udqAAA",
              "RecordType": { "Id": "0125f0000003udqAAA" }
            }
          ]
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "399",
            "conditionText": "extract('CA10__versioningEnabled__c') == true",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-10-07T10:39:40Z" },
          "CA10__disappearanceTime__c": null,
          "CA10__retentionPolicyLock__c": "",
          "CA10__versioningEnabled__c": true,
          "Id": "004",
          "CA10G1__Google_Logging_Log_Sinks__r": [
            {
              "CA10G1__disappearanceTime__c": null,
              "CA10G1__bucket__c": "004",
              "Id": "ls002",
              "RecordTypeId": "0125f0000003udqAAA",
              "RecordType": { "Id": "0125f0000003udqAAA" }
            }
          ]
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "400",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-10-07T10:39:40Z" },
          "CA10__disappearanceTime__c": null,
          "CA10__retentionPolicyLock__c": "",
          "CA10__versioningEnabled__c": false,
          "Id": "005",
          "CA10G1__Google_Logging_Log_Sinks__r": [
            {
              "CA10G1__disappearanceTime__c": null,
              "CA10G1__bucket__c": "005",
              "Id": "ls003",
              "RecordTypeId": "0125f0000003udqAAA",
              "RecordType": { "Id": "0125f0000003udqAAA" }
            }
          ]
        }
      ]
  - path: /types/CA10__CaGoogleStorageBucket__c/object.extracts.yaml
    md5Hash: F35F8474989DF19B98A57A3AFBD1F626
    content: "---\nextracts:\n  - name: \"CA10__levelAccessState__c\"\n    value:\
      \ \n      FIELD:\n        path: \"CA10__levelAccessState__c\"\n  - name: \"\
      CA10__retentionPolicyLock__c\"\n    value: \n      FIELD:\n        path: \"\
      CA10__retentionPolicyLock__c\"\n# Text\n  - name: \"CA10__location__c\"\n  \
      \  value: \n      FIELD:\n        path: \"CA10__location__c\"\n# Checkbox\n\
      \  - name: \"CA10__versioningEnabled__c\"\n    value: \n      FIELD:\n     \
      \   path: \"CA10__versioningEnabled__c\"\n"
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" : "001",
    "expectedResult" : {
      "status" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "002",
    "expectedResult" : {
      "status" : "INAPPLICABLE",
      "conditionIndex" : "199",
      "conditionText" : "CA10G1__Google_Logging_Log_Sinks__r.hasNo(COMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "003",
    "expectedResult" : {
      "status" : "INAPPLICABLE",
      "conditionIndex" : "299",
      "conditionText" : "extract('CA10__retentionPolicyLock__c') == 'Locked'",
      "runtimeError" : null
    }
  }, {
    "Id" : "004",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "399",
      "conditionText" : "extract('CA10__versioningEnabled__c') == true",
      "runtimeError" : null
    }
  }, {
    "Id" : "005",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "400",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaGoogleStorageBucket__c()
  RETURNS ARRAY<STRUCT<
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__retentionPolicyLock__c STRING,
      CA10__versioningEnabled__c BOOLEAN,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-10-07T10:39:40Z")
    },
    "CA10__disappearanceTime__c" : new Date("2024-12-16T11:44:48Z"),
    "CA10__retentionPolicyLock__c" : "",
    "CA10__versioningEnabled__c" : false,
    "Id" : "001"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-07T10:39:40Z")
    },
    "CA10__retentionPolicyLock__c" : "",
    "CA10__versioningEnabled__c" : false,
    "Id" : "002"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-07T10:39:40Z")
    },
    "CA10__retentionPolicyLock__c" : "Locked",
    "CA10__versioningEnabled__c" : false,
    "Id" : "003"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-07T10:39:40Z")
    },
    "CA10__retentionPolicyLock__c" : "",
    "CA10__versioningEnabled__c" : true,
    "Id" : "004"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-07T10:39:40Z")
    },
    "CA10__retentionPolicyLock__c" : "",
    "CA10__versioningEnabled__c" : false,
    "Id" : "005"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10G1__CaGoogleLoggingLogSink__c()
  RETURNS ARRAY<STRUCT<
      CA10G1__disappearanceTime__c TIMESTAMP,
      CA10G1__bucket__c STRING,
      Id STRING,
      RecordTypeId STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-10-07T10:39:40Z")
    },
    "CA10G1__bucket__c" : "003",
    "Id" : "ls001",
    "RecordTypeId" : "0125f0000003udqAAA"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-07T10:39:40Z")
    },
    "CA10G1__bucket__c" : "004",
    "Id" : "ls002",
    "RecordTypeId" : "0125f0000003udqAAA"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-10-07T10:39:40Z")
    },
    "CA10G1__bucket__c" : "005",
    "Id" : "ls003",
    "RecordTypeId" : "0125f0000003udqAAA"
  } ];
  """;

  CREATE TEMP FUNCTION mock_RecordType()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-10-07T10:39:40Z")
    },
    "Id" : "0125f0000003udqAAA"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaGoogleStorageBucket__c(
      obj STRUCT<
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__retentionPolicyLock__c STRING,
          CA10__versioningEnabled__c BOOLEAN,
          Id STRING,
          CA10G1__Google_Logging_Log_Sinks__r ARRAY<STRUCT<
              CA10G1__disappearanceTime__c TIMESTAMP,
              CA10G1__bucket__c STRING,
              Id STRING,
              RecordTypeId STRING,
              RecordType STRUCT<
                  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 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 Google [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};
      }
      var count_CA10G1__Google_Logging_Log_Sinks__r_COMPLIANT2 = 0;
      if (obj.CA10G1__Google_Logging_Log_Sinks__r != null) {
          for (var i3 = 0; i3 < obj.CA10G1__Google_Logging_Log_Sinks__r.length; i3++) {
              if (typeof(obj.CA10G1__Google_Logging_Log_Sinks__r[i3].status) !== 'undefined') {
                  if (obj.CA10G1__Google_Logging_Log_Sinks__r[i3].status == 'COMPLIANT') {
                      count_CA10G1__Google_Logging_Log_Sinks__r_COMPLIANT2 += obj.CA10G1__Google_Logging_Log_Sinks__r[i3].count;
                  }
              } else  {
                  if (obj.CA10G1__Google_Logging_Log_Sinks__r[i3].result.status == 'COMPLIANT') {
                      count_CA10G1__Google_Logging_Log_Sinks__r_COMPLIANT2 += 1;
                  }
              }
          }
      }
      // condition[1], conditionIndex:[100..199]
      references1.push('Related list [CA10G1__Google_Logging_Log_Sinks__r] ' + (count_CA10G1__Google_Logging_Log_Sinks__r_COMPLIANT2 == 0 ? 'does not have' : 'has') + ' objects in COMPLIANT status');
      if (count_CA10G1__Google_Logging_Log_Sinks__r_COMPLIANT2 == 0) {
          return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "CA10G1__Google_Logging_Log_Sinks__r.hasNo(COMPLIANT)", currentStateMessage: "The bucket is a log sink destination.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      function extract5() { if (!this.out) { this.out = obj.CA10__retentionPolicyLock__c; } return this.out; };
      references1.push('Retention Policy: Lock [obj.CA10__retentionPolicyLock__c]: ' + obj.CA10__retentionPolicyLock__c);
      if (TextLib.equal(extract5.call(extract5), 'Locked')) {
          return {status: 'INAPPLICABLE', conditionIndex: 299, conditionText: "extract('CA10__retentionPolicyLock__c') == 'Locked'", currentStateMessage: "The storage bucket has a locked retention policy.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[3], conditionIndex:[300..399]
      function extract8() { if (!this.out) { this.out = obj.CA10__versioningEnabled__c; } return this.out; };
      references1.push('Versioning Enabled [obj.CA10__versioningEnabled__c]: ' + obj.CA10__versioningEnabled__c);
      if (extract8.call(extract8) == true) {
          return {status: 'COMPLIANT', conditionIndex: 399, conditionText: "extract('CA10__versioningEnabled__c') == true", currentStateMessage: "Versioning is enabled on this storage bucket.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'INCOMPLIANT', conditionIndex: 400, conditionText: "otherwise", currentStateMessage: "Versioning is not enabled on this storage bucket.", currentStateReferences: references1.join('\n'), remediation: "Enable Versioning on this bucket.", runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10G1__Google_Logging_Log_Sinks__r(
      obj STRUCT<
          CA10G1__disappearanceTime__c TIMESTAMP,
          CA10G1__bucket__c STRING,
          Id STRING,
          RecordTypeId STRING,
          RecordType STRUCT<
              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 references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From Google [CA10G1__disappearanceTime__c]: ' + obj.CA10G1__disappearanceTime__c);
      if (obj.CA10G1__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10G1__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 100, conditionText: "otherwise", currentStateMessage: "This is a Log Sink with a storage bucket 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.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          sObject.CA10__retentionPolicyLock__c AS CA10__retentionPolicyLock__c,
          sObject.CA10__versioningEnabled__c AS CA10__versioningEnabled__c,
          sObject.Id AS Id,
          `CA10G1__Google_Logging_Log_Sinks__r`.arr AS CA10G1__Google_Logging_Log_Sinks__r,
          process_CA10__CaGoogleStorageBucket__c(
              STRUCT(
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__retentionPolicyLock__c AS CA10__retentionPolicyLock__c,
                  sObject.CA10__versioningEnabled__c AS CA10__versioningEnabled__c,
                  sObject.Id AS Id,
                  `CA10G1__Google_Logging_Log_Sinks__r`.arr AS CA10G1__Google_Logging_Log_Sinks__r
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaGoogleStorageBucket__c()) AS sObject
      LEFT JOIN (
          SELECT
              sObject.CA10G1__bucket__c,
              ARRAY_AGG(
                  STRUCT(
                      sObject.CA10G1__disappearanceTime__c AS CA10G1__disappearanceTime__c,
                      sObject.CA10G1__bucket__c AS CA10G1__bucket__c,
                      sObject.Id AS Id,
                      sObject.RecordTypeId AS RecordTypeId,
                      STRUCT (
                          `RecordType`.Id AS Id
                      ) AS RecordType,
                      process_CA10G1__Google_Logging_Log_Sinks__r(
                          STRUCT(
                              sObject.CA10G1__disappearanceTime__c AS CA10G1__disappearanceTime__c,
                              sObject.CA10G1__bucket__c AS CA10G1__bucket__c,
                              sObject.Id AS Id,
                              sObject.RecordTypeId AS RecordTypeId,
                              STRUCT (
                                  `RecordType`.Id AS Id
                              ) AS RecordType
                          ),
                          sObject.context.snapshotTime
                      ) as result
                  )
              ) AS arr
          FROM UNNEST(mock_CA10G1__CaGoogleLoggingLogSink__c()) AS sObject
          LEFT JOIN UNNEST(mock_RecordType()) AS `RecordType`
              ON sObject.RecordTypeId = `RecordType`.Id
          GROUP BY sObject.CA10G1__bucket__c
      ) AS `CA10G1__Google_Logging_Log_Sinks__r`
          ON sObject.Id = `CA10G1__Google_Logging_Log_Sinks__r`.CA10G1__bucket__c
  ) sObject ON sObject.Id = expectedResult.Id;
