---
policy: /ce/ca/azure/sql-database/elastic-pool-underutilized
logic: /ce/ca/azure/sql-database/elastic-pool-underutilized/prod.logic.yaml
executionTime: 2025-10-01T12:47:07.255232039Z
generationMs: 52
executionMs: 890
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__state__c') != 'Ready'
      actual: extract('CA10__state__c') != 'Ready'
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: extract('CA10__creationDate__c').withinLastDays(30)
      actual: extract('CA10__creationDate__c').withinLastDays(30)
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: UNDETERMINED
      actual: UNDETERMINED
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: extract('CA10__monitorCpuPercentAvg30Day__c').isEmpty() && extract('CA10__monitorStoragePercentAvg30Day__c').isEmpty()
      actual: extract('CA10__monitorCpuPercentAvg30Day__c').isEmpty() && extract('CA10__monitorStoragePercentAvg30Day__c').isEmpty()
    runtimeError: {}
  - id: test5
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 499
      actual: 499
    conditionText:
      expected: extract('CA10__monitorDtuConsumptionPercentAvg30Day__c').isNotEmpty()
        && extract('CA10__monitorDtuConsumptionPercentAvg30Day__c') < number(20.0)
        && extract('CA10__monitorStoragePercentAvg30Day__c') < number(10.0)
      actual: extract('CA10__monitorDtuConsumptionPercentAvg30Day__c').isNotEmpty()
        && extract('CA10__monitorDtuConsumptionPercentAvg30Day__c') < number(20.0)
        && extract('CA10__monitorStoragePercentAvg30Day__c') < number(10.0)
    runtimeError: {}
  - id: test6
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 599
      actual: 599
    conditionText:
      expected: extract('CA10__monitorDtuConsumptionPercentAvg30Day__c').isEmpty()
        && extract('CA10__monitorCpuPercentAvg30Day__c') < number(20.0) && extract('CA10__monitorStoragePercentAvg30Day__c')
        < number(10.0)
      actual: extract('CA10__monitorDtuConsumptionPercentAvg30Day__c').isEmpty() &&
        extract('CA10__monitorCpuPercentAvg30Day__c') < number(20.0) && extract('CA10__monitorStoragePercentAvg30Day__c')
        < number(10.0)
    runtimeError: {}
  - id: test7
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 600
      actual: 600
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/azure/sql-database/elastic-pool-underutilized/policy.yaml
    md5Hash: 575FB048E217330966E791F929E0EA34
    content: "---\nnames:\n  full: Azure SQL Elastic Pool is underutilized\n  contextual:\
      \ Elastic Pool is underutilized\ndescription: >\n  Identifies Azure SQL Elastic\
      \ Pools that are underutilized to optimize costs. \n  An elastic pool is considered\
      \ underutilized if its average DTU/CPU consumption \n  is below 20% and its\
      \ storage utilization is below 10% over the last 30 days.\ntype: \"COMPLIANCE_POLICY\"\
      \ncategories:\n  - \"COST\"\n  - \"PERFORMANCE\"\nframeworkMappings:\n  - \"\
      /frameworks/cloudaware/cost-efficiency-and-optimization/resource-right-sizing\"\
      \n  - \"/frameworks/cloudaware/resource-performance/workload-efficiency\""
  - path: /ce/ca/azure/sql-database/elastic-pool-underutilized/prod.logic.yaml
    md5Hash: 95CD364EC81E44A35124AEBB67709F12
    content: "---\ninputType: \"CA10__CaAzureSqlElasticPool__c\"\nimportExtracts:\n\
      \  - file: \"/types/CA10__CaAzureSqlElasticPool__c/object.extracts.yaml\"\n\
      testData:\n  - file: 'test-data.json'\nconditions:\n  - status: \"INAPPLICABLE\"\
      \n    currentStateMessage: \"The Elastic Pool is not ready.\"\n    check:\n\
      \      NOT_EQUAL:\n        left:\n          EXTRACT: \"CA10__state__c\"\n  \
      \      right:\n          TEXT: \"Ready\"\n  - status: \"INAPPLICABLE\"\n   \
      \ currentStateMessage: \"The Elastic Pool was created in the last 30 days.\"\
      \n    check:\n      IS_WITHIN_LAST_DAYS:\n        offsetDays: 30\n        arg:\n\
      \          EXTRACT: \"CA10__creationDate__c\"\n  - status: \"UNDETERMINED\"\n\
      \    currentStateMessage: \"There is not enough data in the CMDB to identify\
      \ if the Elastic Pool is underutilized.\"\n    check:  \n      AND:  \n    \
      \    args:\n          - IS_EMPTY:\n              arg:\n                EXTRACT:\
      \ \"CA10__monitorCpuPercentAvg30Day__c\"\n          - IS_EMPTY:\n          \
      \    arg:\n                EXTRACT: \"CA10__monitorStoragePercentAvg30Day__c\"\
      \n  - status: \"INCOMPLIANT\"\n    currentStateMessage: \"The Elastic Pool DTU\
      \ consumption is less than 20% and storage utilization is less than 10%.\"\n\
      \    remediationMessage: \"Consider rightsizing the Elastic Pool.\"\n    check:\n\
      \      AND:\n        args:\n          - NOT_EMPTY:\n              arg:\n   \
      \             EXTRACT: \"CA10__monitorDtuConsumptionPercentAvg30Day__c\"\n \
      \         - LESS_THAN:\n              left:\n                EXTRACT: \"CA10__monitorDtuConsumptionPercentAvg30Day__c\"\
      \n              right:\n                NUMBER: 20.0\n          - LESS_THAN:\n\
      \              left:\n                EXTRACT: \"CA10__monitorStoragePercentAvg30Day__c\"\
      \n              right:\n                NUMBER: 10.0\n  - status: \"INCOMPLIANT\"\
      \n    currentStateMessage: \"The Elastic Pool CPU is less than 20% and storage\
      \ utilization is less than 10%.\"\n    remediationMessage: \"Consider rightsizing\
      \ the Elastic Pool.\"\n    check:\n      AND:\n        args:\n          - IS_EMPTY:\n\
      \              arg:\n                EXTRACT: \"CA10__monitorDtuConsumptionPercentAvg30Day__c\"\
      \n          - LESS_THAN:\n              left:\n                EXTRACT: \"CA10__monitorCpuPercentAvg30Day__c\"\
      \n              right:\n                NUMBER: 20.0\n          - LESS_THAN:\n\
      \              left:\n                EXTRACT: \"CA10__monitorStoragePercentAvg30Day__c\"\
      \n              right:\n                NUMBER: 10.0\notherwise:\n  status:\
      \ \"COMPLIANT\"\n  currentStateMessage: \"The Elastic Pool is not underutilized.\""
  - path: /ce/ca/azure/sql-database/elastic-pool-underutilized/test-data.json
    md5Hash: 75D8166F30FDA6046CE4562DDFE4C3FF
    content: |-
      [
          {
              "expectedResult": {
                  "status": "DISAPPEARED",
                  "conditionIndex": "99",
                  "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-09-16T11:43:03Z"
              },
              "Id": "test1",
              "CA10__disappearanceTime__c": "2025-09-16T11:43:03Z",
              "CA10__state__c": "Ready",
              "CA10__creationDate__c": "2019-06-05T11:40:46Z",
              "CA10__monitorCpuPercentAvg30Day__c": 0,
              "CA10__monitorStoragePercentAvg30Day__c": 1,
              "CA10__monitorDtuConsumptionPercentAvg30Day__c": 0
          },
          {
              "expectedResult": {
                  "status": "INAPPLICABLE",
                  "conditionIndex": "199",
                  "conditionText": "extract('CA10__state__c') != 'Ready'",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-09-16T11:43:03Z"
              },
              "Id": "test2",
              "CA10__disappearanceTime__c": null,
              "CA10__state__c": "Error",
              "CA10__creationDate__c": "2019-06-05T11:40:46Z",
              "CA10__monitorCpuPercentAvg30Day__c": 0,
              "CA10__monitorStoragePercentAvg30Day__c": 1,
              "CA10__monitorDtuConsumptionPercentAvg30Day__c": 0
          },
          {
              "expectedResult": {
                  "status": "INAPPLICABLE",
                  "conditionIndex": "299",
                  "conditionText": "extract('CA10__creationDate__c').withinLastDays(30)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-09-16T11:43:03Z"
              },
              "Id": "test3",
              "CA10__disappearanceTime__c": null,
              "CA10__state__c": "Ready",
              "CA10__creationDate__c": "2025-09-01T11:43:03Z",
              "CA10__monitorCpuPercentAvg30Day__c": 0,
              "CA10__monitorStoragePercentAvg30Day__c": 0,
              "CA10__monitorDtuConsumptionPercentAvg30Day__c": null
          },
          {
              "expectedResult": {
                  "status": "UNDETERMINED",
                  "conditionIndex": "399",
                  "conditionText": "extract('CA10__monitorCpuPercentAvg30Day__c').isEmpty() && extract('CA10__monitorStoragePercentAvg30Day__c').isEmpty()",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-09-16T11:43:03Z"
              },
              "Id": "test4",
              "CA10__disappearanceTime__c": null,
              "CA10__state__c": "Ready",
              "CA10__creationDate__c": "2019-01-19T00:12:47Z",
              "CA10__monitorCpuPercentAvg30Day__c": null,
              "CA10__monitorStoragePercentAvg30Day__c": null,
              "CA10__monitorDtuConsumptionPercentAvg30Day__c": null
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "499",
                  "conditionText": "extract('CA10__monitorDtuConsumptionPercentAvg30Day__c').isNotEmpty() && extract('CA10__monitorDtuConsumptionPercentAvg30Day__c') < number(20.0) && extract('CA10__monitorStoragePercentAvg30Day__c') < number(10.0)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-09-16T11:43:03Z"
              },
              "Id": "test5",
              "CA10__disappearanceTime__c": null,
              "CA10__state__c": "Ready",
              "CA10__creationDate__c": "2019-01-19T00:12:47Z",
              "CA10__monitorCpuPercentAvg30Day__c": 5,
              "CA10__monitorStoragePercentAvg30Day__c": 5,
              "CA10__monitorDtuConsumptionPercentAvg30Day__c": 5
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "599",
                  "conditionText": "extract('CA10__monitorDtuConsumptionPercentAvg30Day__c').isEmpty() && extract('CA10__monitorCpuPercentAvg30Day__c') < number(20.0) && extract('CA10__monitorStoragePercentAvg30Day__c') < number(10.0)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-09-16T11:43:03Z"
              },
              "Id": "test6",
              "CA10__disappearanceTime__c": null,
              "CA10__state__c": "Ready",
              "CA10__creationDate__c": "2019-01-19T00:12:47Z",
              "CA10__monitorCpuPercentAvg30Day__c": 5,
              "CA10__monitorStoragePercentAvg30Day__c": 5,
              "CA10__monitorDtuConsumptionPercentAvg30Day__c": null
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "600",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-09-16T11:43:03Z"
              },
              "Id": "test7",
              "CA10__disappearanceTime__c": null,
              "CA10__state__c": "Ready",
              "CA10__creationDate__c": "2019-01-19T00:12:47Z",
              "CA10__monitorCpuPercentAvg30Day__c": 50,
              "CA10__monitorStoragePercentAvg30Day__c": 78,
              "CA10__monitorDtuConsumptionPercentAvg30Day__c": null
          }
      ]
  - path: /types/CA10__CaAzureSqlElasticPool__c/object.extracts.yaml
    md5Hash: 4361B7D3C8748BEE62ADA2B3F84B57E6
    content: "---\nextracts:\n# Not Nullable.\n  - name: \"CA10__state__c\"\n    value:\
      \ \n      FIELD:\n        path: \"CA10__state__c\"\n# Nullable.\n  - name: \"\
      CA10__monitorCpuPercentAvg30Day__c\"\n    value: \n      FIELD:\n        path:\
      \ \"CA10__monitorCpuPercentAvg30Day__c\"\n# Nullable.\n  - name: \"CA10__monitorDtuConsumptionPercentAvg30Day__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__monitorDtuConsumptionPercentAvg30Day__c\"\
      \n#  Nullable.\n  - name: \"CA10__monitorStoragePercentAvg30Day__c\"\n    value:\
      \ \n      FIELD:\n        path: \"CA10__monitorStoragePercentAvg30Day__c\"\n\
      # Not Nullable.\n  - name: \"CA10__creationDate__c\"\n    value: \n      FIELD:\n\
      \        path: \"CA10__creationDate__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" : "test1",
    "expectedResult" : {
      "status" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test2",
    "expectedResult" : {
      "status" : "INAPPLICABLE",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10__state__c') != 'Ready'",
      "runtimeError" : null
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "status" : "INAPPLICABLE",
      "conditionIndex" : "299",
      "conditionText" : "extract('CA10__creationDate__c').withinLastDays(30)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "status" : "UNDETERMINED",
      "conditionIndex" : "399",
      "conditionText" : "extract('CA10__monitorCpuPercentAvg30Day__c').isEmpty() && extract('CA10__monitorStoragePercentAvg30Day__c').isEmpty()",
      "runtimeError" : null
    }
  }, {
    "Id" : "test5",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "499",
      "conditionText" : "extract('CA10__monitorDtuConsumptionPercentAvg30Day__c').isNotEmpty() && extract('CA10__monitorDtuConsumptionPercentAvg30Day__c') < number(20.0) && extract('CA10__monitorStoragePercentAvg30Day__c') < number(10.0)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test6",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "599",
      "conditionText" : "extract('CA10__monitorDtuConsumptionPercentAvg30Day__c').isEmpty() && extract('CA10__monitorCpuPercentAvg30Day__c') < number(20.0) && extract('CA10__monitorStoragePercentAvg30Day__c') < number(10.0)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test7",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "600",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureSqlElasticPool__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__state__c STRING,
      CA10__creationDate__c TIMESTAMP,
      CA10__monitorCpuPercentAvg30Day__c FLOAT64,
      CA10__monitorStoragePercentAvg30Day__c FLOAT64,
      CA10__monitorDtuConsumptionPercentAvg30Day__c FLOAT64,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-09-16T11:43:03Z")
    },
    "Id" : "test1",
    "CA10__disappearanceTime__c" : new Date("2025-09-16T11:43:03Z"),
    "CA10__state__c" : "Ready",
    "CA10__creationDate__c" : new Date("2019-06-05T11:40:46Z"),
    "CA10__monitorCpuPercentAvg30Day__c" : 0,
    "CA10__monitorStoragePercentAvg30Day__c" : 1,
    "CA10__monitorDtuConsumptionPercentAvg30Day__c" : 0
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-09-16T11:43:03Z")
    },
    "Id" : "test2",
    "CA10__state__c" : "Error",
    "CA10__creationDate__c" : new Date("2019-06-05T11:40:46Z"),
    "CA10__monitorCpuPercentAvg30Day__c" : 0,
    "CA10__monitorStoragePercentAvg30Day__c" : 1,
    "CA10__monitorDtuConsumptionPercentAvg30Day__c" : 0
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-09-16T11:43:03Z")
    },
    "Id" : "test3",
    "CA10__state__c" : "Ready",
    "CA10__creationDate__c" : new Date("2025-09-01T11:43:03Z"),
    "CA10__monitorCpuPercentAvg30Day__c" : 0,
    "CA10__monitorStoragePercentAvg30Day__c" : 0,
    "CA10__monitorDtuConsumptionPercentAvg30Day__c" : null
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-09-16T11:43:03Z")
    },
    "Id" : "test4",
    "CA10__state__c" : "Ready",
    "CA10__creationDate__c" : new Date("2019-01-19T00:12:47Z"),
    "CA10__monitorCpuPercentAvg30Day__c" : null,
    "CA10__monitorStoragePercentAvg30Day__c" : null,
    "CA10__monitorDtuConsumptionPercentAvg30Day__c" : null
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-09-16T11:43:03Z")
    },
    "Id" : "test5",
    "CA10__state__c" : "Ready",
    "CA10__creationDate__c" : new Date("2019-01-19T00:12:47Z"),
    "CA10__monitorCpuPercentAvg30Day__c" : 5,
    "CA10__monitorStoragePercentAvg30Day__c" : 5,
    "CA10__monitorDtuConsumptionPercentAvg30Day__c" : 5
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-09-16T11:43:03Z")
    },
    "Id" : "test6",
    "CA10__state__c" : "Ready",
    "CA10__creationDate__c" : new Date("2019-01-19T00:12:47Z"),
    "CA10__monitorCpuPercentAvg30Day__c" : 5,
    "CA10__monitorStoragePercentAvg30Day__c" : 5,
    "CA10__monitorDtuConsumptionPercentAvg30Day__c" : null
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-09-16T11:43:03Z")
    },
    "Id" : "test7",
    "CA10__state__c" : "Ready",
    "CA10__creationDate__c" : new Date("2019-01-19T00:12:47Z"),
    "CA10__monitorCpuPercentAvg30Day__c" : 50,
    "CA10__monitorStoragePercentAvg30Day__c" : 78,
    "CA10__monitorDtuConsumptionPercentAvg30Day__c" : null
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAzureSqlElasticPool__c(
      obj STRUCT<
          Id STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__state__c STRING,
          CA10__creationDate__c TIMESTAMP,
          CA10__monitorCpuPercentAvg30Day__c FLOAT64,
          CA10__monitorStoragePercentAvg30Day__c FLOAT64,
          CA10__monitorDtuConsumptionPercentAvg30Day__c FLOAT64
      >,
      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 todayMinus30Day = new Date(snapshotTime.toISOString().substr(0,10)+'T00:00:00.000Z').getTime() + (-30 * 86400000);
      var todayPlus1Day = new Date(snapshotTime.toISOString().substr(0,10)+'T00:00:00.000Z').getTime() + (1 * 86400000);
      var IsEmptyLib = new function () {
          this.simpleIsEmpty = function(arg) {
              return arg == null;
          };
          this.simpleIsNotEmpty = function(arg) {
              return arg != null;
          };
      }();
      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]
      function extract3() { if (!this.out) { this.out = obj.CA10__state__c; } return this.out; };
      references1.push('State [obj.CA10__state__c]: ' + obj.CA10__state__c);
      if (TextLib.notEqual(extract3.call(extract3), 'Ready')) {
          return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10__state__c') != 'Ready'", currentStateMessage: "The Elastic Pool is not ready.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      function extract6() { if (!this.out) { this.out = obj.CA10__creationDate__c; } return this.out; };
      references1.push('Creation Date [obj.CA10__creationDate__c]: ' + obj.CA10__creationDate__c);
      if (extract6.call(extract6) != null && extract6.call(extract6).getTime() >= todayMinus30Day && extract6.call(extract6).getTime() < todayPlus1Day) {
          return {status: 'INAPPLICABLE', conditionIndex: 299, conditionText: "extract('CA10__creationDate__c').withinLastDays(30)", currentStateMessage: "The Elastic Pool was created in the last 30 days.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[3], conditionIndex:[300..399]
      function extract10() { if (!this.out) { this.out = obj.CA10__monitorCpuPercentAvg30Day__c; } return this.out; };
      function extract13() { if (!this.out) { this.out = obj.CA10__monitorStoragePercentAvg30Day__c; } return this.out; };
      references1.push('Monitor: CPU Percent, 30-Day [obj.CA10__monitorCpuPercentAvg30Day__c]: ' + obj.CA10__monitorCpuPercentAvg30Day__c);
      references1.push('Monitor: Storage Percent, 30-Day [obj.CA10__monitorStoragePercentAvg30Day__c]: ' + obj.CA10__monitorStoragePercentAvg30Day__c);
      if (IsEmptyLib.simpleIsEmpty(extract10.call(extract10)) && IsEmptyLib.simpleIsEmpty(extract13.call(extract13))) {
          return {status: 'UNDETERMINED', conditionIndex: 399, conditionText: "extract('CA10__monitorCpuPercentAvg30Day__c').isEmpty() && extract('CA10__monitorStoragePercentAvg30Day__c').isEmpty()", currentStateMessage: "There is not enough data in the CMDB to identify if the Elastic Pool is underutilized.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[4], conditionIndex:[400..499]
      function extract16() { if (!this.out) { this.out = obj.CA10__monitorDtuConsumptionPercentAvg30Day__c; } return this.out; };
      function extract22() { if (!this.out) { this.out = obj.CA10__monitorStoragePercentAvg30Day__c; } return this.out; };
      references1.push('Monitor: DTU Consumption Percent, 30-Day [obj.CA10__monitorDtuConsumptionPercentAvg30Day__c]: ' + obj.CA10__monitorDtuConsumptionPercentAvg30Day__c);
      if (IsEmptyLib.simpleIsNotEmpty(extract16.call(extract16)) && (extract16.call(extract16) != null && 20.0 != null && extract16.call(extract16) < 20.0) && (extract22.call(extract22) != null && 10.0 != null && extract22.call(extract22) < 10.0)) {
          return {status: 'INCOMPLIANT', conditionIndex: 499, conditionText: "extract('CA10__monitorDtuConsumptionPercentAvg30Day__c').isNotEmpty() && extract('CA10__monitorDtuConsumptionPercentAvg30Day__c') < number(20.0) && extract('CA10__monitorStoragePercentAvg30Day__c') < number(10.0)", currentStateMessage: "The Elastic Pool DTU consumption is less than 20% and storage utilization is less than 10%.", currentStateReferences: references1.join('\n'), remediation: "Consider rightsizing the Elastic Pool.", runtimeError: null};
      }
      // condition[5], conditionIndex:[500..599]
      function extract25() { if (!this.out) { this.out = obj.CA10__monitorDtuConsumptionPercentAvg30Day__c; } return this.out; };
      function extract29() { if (!this.out) { this.out = obj.CA10__monitorCpuPercentAvg30Day__c; } return this.out; };
      function extract33() { if (!this.out) { this.out = obj.CA10__monitorStoragePercentAvg30Day__c; } return this.out; };
      if (IsEmptyLib.simpleIsEmpty(extract25.call(extract25)) && (extract29.call(extract29) != null && 20.0 != null && extract29.call(extract29) < 20.0) && (extract33.call(extract33) != null && 10.0 != null && extract33.call(extract33) < 10.0)) {
          return {status: 'INCOMPLIANT', conditionIndex: 599, conditionText: "extract('CA10__monitorDtuConsumptionPercentAvg30Day__c').isEmpty() && extract('CA10__monitorCpuPercentAvg30Day__c') < number(20.0) && extract('CA10__monitorStoragePercentAvg30Day__c') < number(10.0)", currentStateMessage: "The Elastic Pool CPU is less than 20% and storage utilization is less than 10%.", currentStateReferences: references1.join('\n'), remediation: "Consider rightsizing the Elastic Pool.", runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 600, conditionText: "otherwise", currentStateMessage: "The Elastic Pool is not underutilized.", 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__state__c AS CA10__state__c,
          sObject.CA10__creationDate__c AS CA10__creationDate__c,
          sObject.CA10__monitorCpuPercentAvg30Day__c AS CA10__monitorCpuPercentAvg30Day__c,
          sObject.CA10__monitorStoragePercentAvg30Day__c AS CA10__monitorStoragePercentAvg30Day__c,
          sObject.CA10__monitorDtuConsumptionPercentAvg30Day__c AS CA10__monitorDtuConsumptionPercentAvg30Day__c,
          process_CA10__CaAzureSqlElasticPool__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__state__c AS CA10__state__c,
                  sObject.CA10__creationDate__c AS CA10__creationDate__c,
                  sObject.CA10__monitorCpuPercentAvg30Day__c AS CA10__monitorCpuPercentAvg30Day__c,
                  sObject.CA10__monitorStoragePercentAvg30Day__c AS CA10__monitorStoragePercentAvg30Day__c,
                  sObject.CA10__monitorDtuConsumptionPercentAvg30Day__c AS CA10__monitorDtuConsumptionPercentAvg30Day__c
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAzureSqlElasticPool__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
