---
policy: /ce/ca/aws/dynamodb/table-auto-scaling
logic: /ce/ca/aws/dynamodb/table-auto-scaling/prod.logic.yaml
executionTime: 2025-07-25T15:25:51.945639339Z
rows:
  - id: test1
    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: test2
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10__billingMode__c') == 'PAY_PER_REQUEST'
      actual: extract('CA10__billingMode__c') == 'PAY_PER_REQUEST'
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: CA10__AWS_App_AutoScaling_Scalable_Targets__r.has(COMPLIANT)
      actual: CA10__AWS_App_AutoScaling_Scalable_Targets__r.has(COMPLIANT)
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: CA10__AWS_App_AutoScaling_Scalable_Targets__r.has(COMPLIANT)
      actual: CA10__AWS_App_AutoScaling_Scalable_Targets__r.has(COMPLIANT)
    runtimeError: {}
  - id: test5
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 300
      actual: 300
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: test6
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 300
      actual: 300
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: test7
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 300
      actual: 300
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/dynamodb/table-auto-scaling/policy.yaml
    md5Hash: 157C7B6CE439C70671361F818EBB6A51
    content: "---\nnames:\n  full: AWS DynamoDB Provisioned Table Auto Scaling is\
      \ not configured\n  contextual: Provisioned Table Auto Scaling is not configured\n\
      description: >\n  Ensure that Amazon DynamoDB tables are configured to automatically\
      \ scale read \n  and write capacity to meet demand. This can be achieved by\
      \ using On-Demand \n  capacity mode or by configuring Auto Scaling for provisioned\
      \ throughput. This \n  helps maintain performance during traffic spikes and\
      \ can optimize costs during \n  periods of low activity.\ntype: COMPLIANCE_POLICY\n\
      categories:\n  - SECURITY\nframeworkMappings:\n  - \"/frameworks/cloudaware/cost-efficiency-and-optimization/resource-optimization\"\
      \n  - \"/frameworks/cloudaware/resource-performance/workload-efficiency\"\n\
      \  - \"/frameworks/aws-fsbp-v1.0.0/dynamodb/01\"\nsimilarPolicies:\n  awsSecurityHub:\n\
      \    - name: \"[DynamoDB.1] DynamoDB tables should automatically scale capacity\
      \ with demand\"\n      url: \"https://docs.aws.amazon.com/securityhub/latest/userguide/dynamodb-controls.html#dynamodb-1\"\
      \n  internal:\n    - \"dec-x-17b4855f\""
  - path: /ce/ca/aws/dynamodb/table-auto-scaling/prod.logic.yaml
    md5Hash: DC549E250701F034377DA2FCE9BB6A64
    content: |-
      inputType: "CA10__CaAwsDynamoDbTable__c"
      testData:
       - file: test-data.json
      importExtracts:
       - file: /types/CA10__CaAwsDynamoDbTable__c/object.extracts.yaml
      conditions:
        - status: "INAPPLICABLE"
          currentStateMessage: "The DynamoDB Table uses On-Demand capacity mode, which scales automatically."
          check:
            IS_EQUAL:
              left:
                EXTRACT: "CA10__billingMode__c"
              right:
                TEXT: "PAY_PER_REQUEST"
        - status: "COMPLIANT"
          currentStateMessage: "The DynamoDB Table uses Provisioned capacity mode with Auto Scaling enabled."
          check:
            RELATED_LIST_HAS:
              status: "COMPLIANT"
              relationshipName: "CA10__AWS_App_AutoScaling_Scalable_Targets__r"
      otherwise:
        status: "INCOMPLIANT"
        currentStateMessage: "The DynamoDB Table uses Provisioned capacity mode without Auto Scaling configured."
        remediationMessage: "Enable DynamoDB Auto Scaling for the Table or switch to On-Demand capacity mode."
      relatedLists:
        - relationshipName: "CA10__AWS_App_AutoScaling_Scalable_Targets__r"
          conditions: []
          otherwise:
            status: "COMPLIANT"
            currentStateMessage: "An Auto Scaling configuration exists for this table."
  - path: /types/CA10__CaAwsDynamoDbTable__c/object.extracts.yaml
    md5Hash: EB356A351A5AB0BB2575E0F65DA30F2E
    content: "---\nextracts:\n# Nullable, null is equal to PROVISIONED\n  - name:\
      \ \"CA10__billingMode__c\"\n    value:\n      FIELD:\n        path: CA10__billingMode__c\n\
      \        # undeterminedIf:\n        #   noAccessDelegate:\n        #     path:\
      \ \"CA10__billingMode__c\"\n        #     currentStateMessage: \"Unable to determine\
      \ Table Billing Mode. Possible permission issue with dynamodb:DescribeTable.\"\
      \n# Values: ENABLED | DISABLED. Not nullable. \n  - name: \"CA10__pointInTimeRecoveryStatus__c\"\
      \n    value:\n      FIELD:\n        path: CA10__pointInTimeRecoveryStatus__c\n\
      \        # undeterminedIf:\n        #   noAccessDelegate:\n        #     path:\
      \ \"CA10__pointInTimeRecoveryStatus__c\"\n        #     currentStateMessage:\
      \ \"Unable to determine Point In Time Recovery Status. Possible permission issue\
      \ with dynamodb:DescribeTable.\"\n"
  - path: /ce/ca/aws/dynamodb/table-auto-scaling/test-data.json
    md5Hash: E2C7F23AEA33381509C01B280AB20064
    content: |-
      [
          {
              "expectedResult": {
                  "status": "DISAPPEARED",
                  "conditionIndex": "99",
                  "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-07-21T14:26:56Z"
              },
              "Id": "test1",
              "CA10__disappearanceTime__c": "2025-07-21T14:26:56Z",
              "CA10__billingMode__c": "PAY_PER_REQUEST",
              "CA10__AWS_App_AutoScaling_Scalable_Targets__r": []
          },
          {
              "expectedResult": {
                  "status": "INAPPLICABLE",
                  "conditionIndex": "199",
                  "conditionText": "extract('CA10__billingMode__c') == 'PAY_PER_REQUEST'",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-07-21T14:26:56Z"
              },
              "Id": "test2",
              "CA10__disappearanceTime__c": null,
              "CA10__billingMode__c": "PAY_PER_REQUEST",
              "CA10__AWS_App_AutoScaling_Scalable_Targets__r": []
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "CA10__AWS_App_AutoScaling_Scalable_Targets__r.has(COMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-07-21T14:26:56Z"
              },
              "Id": "test3",
              "CA10__disappearanceTime__c": null,
              "CA10__billingMode__c": "",
              "CA10__AWS_App_AutoScaling_Scalable_Targets__r": [
                  {
                      "Id": "test3_1",
                      "RecordTypeId": "RecordTypeId",
                      "CA10__disappearanceTime__c": null,
                      "CA10__dynamoDbTable__c": "test3",
                      "RecordType": {
                          "DeveloperName": "caAwsAppAutoScalingScalableTargetDynamoDb",
                          "Id": "RecordTypeId"
                      }
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "CA10__AWS_App_AutoScaling_Scalable_Targets__r.has(COMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-07-21T14:26:56Z"
              },
              "Id": "test4",
              "CA10__disappearanceTime__c": null,
              "CA10__billingMode__c": "PROVISIONED",
              "CA10__AWS_App_AutoScaling_Scalable_Targets__r": [
                  {
                      "Id": "test4_1",
                      "RecordTypeId": "RecordTypeId",
                      "CA10__disappearanceTime__c": null,
                      "CA10__dynamoDbTable__c": "test4",
                      "RecordType": {
                          "DeveloperName": "caAwsAppAutoScalingScalableTargetDynamoDb",
                          "Id": "RecordTypeId"
                      }
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "300",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-07-21T14:26:56Z"
              },
              "Id": "test5",
              "CA10__disappearanceTime__c": null,
              "CA10__billingMode__c": "",
              "CA10__AWS_App_AutoScaling_Scalable_Targets__r": []
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "300",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-07-21T14:26:56Z"
              },
              "Id": "test6",
              "CA10__disappearanceTime__c": null,
              "CA10__billingMode__c": "PROVISIONED",
              "CA10__AWS_App_AutoScaling_Scalable_Targets__r": []
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "300",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-07-21T14:26:56Z"
              },
              "Id": "test7",
              "CA10__disappearanceTime__c": null,
              "CA10__billingMode__c": "PROVISIONED",
              "CA10__AWS_App_AutoScaling_Scalable_Targets__r": [
                  {
                      "Id": "test7_1",
                      "RecordTypeId": "RecordTypeId",
                      "CA10__disappearanceTime__c": "2025-07-21T14:26:56Z",
                      "CA10__dynamoDbTable__c": "test7",
                      "RecordType": {
                          "DeveloperName": "caAwsAppAutoScalingScalableTargetDynamoDb",
                          "Id": "RecordTypeId"
                      }
                  }
              ]
          }
      ]
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" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test2",
    "expectedResult" : {
      "status" : "INAPPLICABLE",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10__billingMode__c') == 'PAY_PER_REQUEST'",
      "runtimeError" : null
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "CA10__AWS_App_AutoScaling_Scalable_Targets__r.has(COMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "CA10__AWS_App_AutoScaling_Scalable_Targets__r.has(COMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test5",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "300",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "test6",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "300",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "test7",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "300",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsDynamoDbTable__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__billingMode__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-07-21T14:26:56Z")
    },
    "Id" : "test1",
    "CA10__disappearanceTime__c" : new Date("2025-07-21T14:26:56Z"),
    "CA10__billingMode__c" : "PAY_PER_REQUEST"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-21T14:26:56Z")
    },
    "Id" : "test2",
    "CA10__billingMode__c" : "PAY_PER_REQUEST"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-21T14:26:56Z")
    },
    "Id" : "test3",
    "CA10__billingMode__c" : ""
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-21T14:26:56Z")
    },
    "Id" : "test4",
    "CA10__billingMode__c" : "PROVISIONED"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-21T14:26:56Z")
    },
    "Id" : "test5",
    "CA10__billingMode__c" : ""
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-21T14:26:56Z")
    },
    "Id" : "test6",
    "CA10__billingMode__c" : "PROVISIONED"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-21T14:26:56Z")
    },
    "Id" : "test7",
    "CA10__billingMode__c" : "PROVISIONED"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsAppAutoScalingScalableTarget__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      RecordTypeId STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__dynamoDbTable__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-07-21T14:26:56Z")
    },
    "Id" : "test3_1",
    "RecordTypeId" : "RecordTypeId",
    "CA10__dynamoDbTable__c" : "test3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-21T14:26:56Z")
    },
    "Id" : "test4_1",
    "RecordTypeId" : "RecordTypeId",
    "CA10__dynamoDbTable__c" : "test4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-07-21T14:26:56Z")
    },
    "Id" : "test7_1",
    "RecordTypeId" : "RecordTypeId",
    "CA10__disappearanceTime__c" : new Date("2025-07-21T14:26:56Z"),
    "CA10__dynamoDbTable__c" : "test7"
  } ];
  """;

  CREATE TEMP FUNCTION mock_RecordType()
  RETURNS ARRAY<STRUCT<
      DeveloperName STRING,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-07-21T14:26:56Z")
    },
    "DeveloperName" : "caAwsAppAutoScalingScalableTargetDynamoDb",
    "Id" : "RecordTypeId"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAwsDynamoDbTable__c(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__billingMode__c STRING,
          CA10__AWS_App_AutoScaling_Scalable_Targets__r ARRAY<STRUCT<
              Id STRING,
              RecordTypeId STRING,
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__dynamoDbTable__c STRING,
              RecordType STRUCT<
                  DeveloperName 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 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 extract3() { if (!this.out) { this.out = obj.CA10__billingMode__c; } return this.out; };
      references1.push('Billing Mode [obj.CA10__billingMode__c]: ' + obj.CA10__billingMode__c);
      if (TextLib.equal(extract3.call(extract3), 'PAY_PER_REQUEST')) {
          return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10__billingMode__c') == 'PAY_PER_REQUEST'", currentStateMessage: "The DynamoDB Table uses On-Demand capacity mode, which scales automatically.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      var count_CA10__AWS_App_AutoScaling_Scalable_Targets__r_COMPLIANT5 = 0;
      if (obj.CA10__AWS_App_AutoScaling_Scalable_Targets__r != null) {
          for (var i6 = 0; i6 < obj.CA10__AWS_App_AutoScaling_Scalable_Targets__r.length; i6++) {
              if (obj.CA10__AWS_App_AutoScaling_Scalable_Targets__r[i6].result.status == 'COMPLIANT') {
                  count_CA10__AWS_App_AutoScaling_Scalable_Targets__r_COMPLIANT5 += 1;
              }
          }
      }
      // condition[2], conditionIndex:[200..299]
      references1.push('Related list [CA10__AWS_App_AutoScaling_Scalable_Targets__r] ' + (count_CA10__AWS_App_AutoScaling_Scalable_Targets__r_COMPLIANT5 > 0 ? 'has' : 'does not have') + ' objects in COMPLIANT status');
      if (count_CA10__AWS_App_AutoScaling_Scalable_Targets__r_COMPLIANT5 > 0) {
          return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "CA10__AWS_App_AutoScaling_Scalable_Targets__r.has(COMPLIANT)", currentStateMessage: "The DynamoDB Table uses Provisioned capacity mode with Auto Scaling enabled.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'INCOMPLIANT', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "The DynamoDB Table uses Provisioned capacity mode without Auto Scaling configured.", currentStateReferences: references1.join('\n'), remediation: "Enable DynamoDB Auto Scaling for the Table or switch to On-Demand capacity mode.", runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10__AWS_App_AutoScaling_Scalable_Targets__r(
      obj STRUCT<
          Id STRING,
          RecordTypeId STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__dynamoDbTable__c STRING,
          RecordType STRUCT<
              DeveloperName 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 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};
      }
      return {status: 'COMPLIANT', conditionIndex: 100, conditionText: "otherwise", currentStateMessage: "An Auto Scaling configuration exists for this table.", 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,
          sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          sObject.CA10__billingMode__c AS CA10__billingMode__c,
          `CA10__AWS_App_AutoScaling_Scalable_Targets__r`.arr AS CA10__AWS_App_AutoScaling_Scalable_Targets__r,
          process_CA10__CaAwsDynamoDbTable__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__billingMode__c AS CA10__billingMode__c,
                  `CA10__AWS_App_AutoScaling_Scalable_Targets__r`.arr AS CA10__AWS_App_AutoScaling_Scalable_Targets__r
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAwsDynamoDbTable__c()) AS sObject
      LEFT JOIN (
          SELECT
              sObject.CA10__dynamoDbTable__c,
              ARRAY_AGG(
                  STRUCT(
                      sObject.Id AS Id,
                      sObject.RecordTypeId AS RecordTypeId,
                      sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                      sObject.CA10__dynamoDbTable__c AS CA10__dynamoDbTable__c,
                      STRUCT (
                          `RecordType`.DeveloperName AS DeveloperName,
                          `RecordType`.Id AS Id
                      ) AS RecordType,
                      process_CA10__AWS_App_AutoScaling_Scalable_Targets__r(
                          STRUCT(
                              sObject.Id AS Id,
                              sObject.RecordTypeId AS RecordTypeId,
                              sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                              sObject.CA10__dynamoDbTable__c AS CA10__dynamoDbTable__c,
                              STRUCT (
                                  `RecordType`.DeveloperName AS DeveloperName,
                                  `RecordType`.Id AS Id
                              ) AS RecordType
                          ),
                          sObject.context.snapshotTime
                      ) as result
                  )
              ) AS arr
          FROM UNNEST(mock_CA10__CaAwsAppAutoScalingScalableTarget__c()) AS sObject
          LEFT JOIN UNNEST(mock_RecordType()) AS `RecordType`
              ON sObject.RecordTypeId = `RecordType`.Id
          GROUP BY sObject.CA10__dynamoDbTable__c
      ) AS `CA10__AWS_App_AutoScaling_Scalable_Targets__r`
          ON sObject.Id = `CA10__AWS_App_AutoScaling_Scalable_Targets__r`.CA10__dynamoDbTable__c
  ) sObject ON sObject.Id = expectedResult.Id;
