---
policy: /ce/ca/azure/mysql-database/server-underutilized
logic: /ce/ca/azure/mysql-database/server-underutilized/prod.logic.yaml
executionTime: 2025-10-01T12:46:47.966979903Z
generationMs: 68
executionMs: 706
rows:
  - id: '001'
    match: true
    status:
      expected: DISAPPEARED
      actual: DISAPPEARED
    conditionIndex:
      expected: 99
      actual: 99
    conditionText:
      expected: isDisappeared(CA10Z1__disappearanceTime__c)
      actual: isDisappeared(CA10Z1__disappearanceTime__c)
    runtimeError: {}
  - id: '002'
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10Z1__state__c') != 'Ready'
      actual: extract('CA10Z1__state__c') != 'Ready'
    runtimeError: {}
  - id: '003'
    match: true
    status:
      expected: UNDETERMINED
      actual: UNDETERMINED
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: extract('CA10Z1__monitorCpuPercentAvg30Day__c').isEmpty() || extract('CA10Z1__monitorMemoryPercentAvg30Day__c').isEmpty()
        || extract('CA10Z1__monitorIoConsumptionPercentAvg30Day__c').isEmpty()
      actual: extract('CA10Z1__monitorCpuPercentAvg30Day__c').isEmpty() || extract('CA10Z1__monitorMemoryPercentAvg30Day__c').isEmpty()
        || extract('CA10Z1__monitorIoConsumptionPercentAvg30Day__c').isEmpty()
    runtimeError: {}
  - id: '004'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: extract('CA10Z1__monitorCpuPercentAvg30Day__c') < number(20.0) &&
        extract('CA10Z1__monitorMemoryPercentAvg30Day__c') < number(40.0) && extract('CA10Z1__monitorIoConsumptionPercentAvg30Day__c')
        < number(20.0)
      actual: extract('CA10Z1__monitorCpuPercentAvg30Day__c') < number(20.0) && extract('CA10Z1__monitorMemoryPercentAvg30Day__c')
        < number(40.0) && extract('CA10Z1__monitorIoConsumptionPercentAvg30Day__c')
        < number(20.0)
    runtimeError: {}
  - id: '005'
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 400
      actual: 400
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: '006'
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 400
      actual: 400
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/azure/mysql-database/server-underutilized/policy.yaml
    md5Hash: 6A6379E817B92DAD0C45B90ACBC983E5
    content: "---\nnames:\n  full: Azure MySQL Server is underutilized\n  contextual:\
      \ Server is underutilized\ndescription: >\n  Identify underutilized Azure MySQL\
      \ Servers to optimize costs and improve efficiency. \n  Servers are considered\
      \ underutilized if their average CPU and I/O utilization are \n  consistently\
      \ below 20% and memory below is 40% over a 30-day period.\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/mysql-database/server-underutilized/prod.logic.yaml
    md5Hash: AD1E462399289F4DCB71244639026ED4
    content: |-
      ---
      inputType: "CA10Z1__CaAzureMySqlServer__c"
      importExtracts:
        - file: "/types/CA10Z1__CaAzureMySqlServer__c/object.extracts.yaml"
      testData:
        - file: 'test-data.json'
      conditions:
        - status: "INAPPLICABLE"
          currentStateMessage: "The server is not ready."
          check:
            NOT_EQUAL:
              left:
                EXTRACT: "CA10Z1__state__c"
              right:
                TEXT: "Ready"
        - status: UNDETERMINED
          currentStateMessage: "There is not enough data in the CMDB to identify if the server is underutilized."
          check:
            OR:
              args:
                - IS_EMPTY:
                    arg:
                      EXTRACT: "CA10Z1__monitorCpuPercentAvg30Day__c"
                - IS_EMPTY:
                    arg:
                      EXTRACT: "CA10Z1__monitorMemoryPercentAvg30Day__c"
                - IS_EMPTY:
                    arg:
                      EXTRACT: "CA10Z1__monitorIoConsumptionPercentAvg30Day__c"
        - status: "INCOMPLIANT"
          currentStateMessage: "The server is underutilized with Average CPU and IO < 20%, and Memory Utilization < 40%."
          remediationMessage: "Consider rightsizing, the server."
          check:
            AND:
              args:
                - LESS_THAN:
                    left:
                      EXTRACT: "CA10Z1__monitorCpuPercentAvg30Day__c"
                    right:
                      NUMBER: 20.0
                - LESS_THAN:
                    left:
                      EXTRACT: "CA10Z1__monitorMemoryPercentAvg30Day__c"
                    right:
                      NUMBER: 40.0
                - LESS_THAN:
                    left:
                      EXTRACT: "CA10Z1__monitorIoConsumptionPercentAvg30Day__c"
                    right:
                      NUMBER: 20.0
      otherwise:
        status: "COMPLIANT"
        currentStateMessage: "The server is not underutilized."
  - path: /ce/ca/azure/mysql-database/server-underutilized/test-data.json
    md5Hash: 354F26613066484B452C387E85FCF6BC
    content: |-
      [
          {
              "expectedResult": {
                  "status": "DISAPPEARED",
                  "conditionIndex": "99",
                  "conditionText": "isDisappeared(CA10Z1__disappearanceTime__c)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-09-17T01:22:29Z"
              },
              "Id": "001",
              "CA10Z1__disappearanceTime__c": "2025-09-17T01:22:29Z",
              "CA10Z1__state__c": "Ready",
              "CA10Z1__monitorCpuPercentAvg30Day__c": 10,
              "CA10Z1__monitorMemoryPercentAvg30Day__c": 10,
              "CA10Z1__monitorIoConsumptionPercentAvg30Day__c": 10
          },
          {
              "expectedResult": {
                  "status": "INAPPLICABLE",
                  "conditionIndex": "199",
                  "conditionText": "extract('CA10Z1__state__c') != 'Ready'",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-09-17T01:22:29Z"
              },
              "Id": "002",
              "CA10Z1__disappearanceTime__c": null,
              "CA10Z1__state__c": "Error",
              "CA10Z1__monitorCpuPercentAvg30Day__c": 10,
              "CA10Z1__monitorMemoryPercentAvg30Day__c": 10,
              "CA10Z1__monitorIoConsumptionPercentAvg30Day__c": 10
          },
          {
              "expectedResult": {
                  "status": "UNDETERMINED",
                  "conditionIndex": "299",
                  "conditionText": "extract('CA10Z1__monitorCpuPercentAvg30Day__c').isEmpty() || extract('CA10Z1__monitorMemoryPercentAvg30Day__c').isEmpty() || extract('CA10Z1__monitorIoConsumptionPercentAvg30Day__c').isEmpty()",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-09-17T01:22:29Z"
              },
              "Id": "003",
              "CA10Z1__disappearanceTime__c": null,
              "CA10Z1__state__c": "Ready",
              "CA10Z1__monitorCpuPercentAvg30Day__c": null,
              "CA10Z1__monitorMemoryPercentAvg30Day__c": null,
              "CA10Z1__monitorIoConsumptionPercentAvg30Day__c": null
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "399",
                  "conditionText": "extract('CA10Z1__monitorCpuPercentAvg30Day__c') < number(20.0) && extract('CA10Z1__monitorMemoryPercentAvg30Day__c') < number(40.0) && extract('CA10Z1__monitorIoConsumptionPercentAvg30Day__c') < number(20.0)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-09-17T01:22:29Z"
              },
              "Id": "004",
              "CA10Z1__disappearanceTime__c": null,
              "CA10Z1__state__c": "Ready",
              "CA10Z1__monitorCpuPercentAvg30Day__c": 10,
              "CA10Z1__monitorMemoryPercentAvg30Day__c": 10,
              "CA10Z1__monitorIoConsumptionPercentAvg30Day__c": 10
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "400",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-09-17T01:22:29Z"
              },
              "Id": "005",
              "CA10Z1__disappearanceTime__c": null,
              "CA10Z1__state__c": "Ready",
              "CA10Z1__monitorCpuPercentAvg30Day__c": 20,
              "CA10Z1__monitorMemoryPercentAvg30Day__c": 40,
              "CA10Z1__monitorIoConsumptionPercentAvg30Day__c": 20
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "400",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2025-09-17T01:22:29Z"
              },
              "Id": "006",
              "CA10Z1__disappearanceTime__c": null,
              "CA10Z1__state__c": "Ready",
              "CA10Z1__monitorCpuPercentAvg30Day__c": 50,
              "CA10Z1__monitorMemoryPercentAvg30Day__c": 50,
              "CA10Z1__monitorIoConsumptionPercentAvg30Day__c": 50
          }
      ]
  - path: /types/CA10Z1__CaAzureMySqlServer__c/object.extracts.yaml
    md5Hash: 2B2178E89E751C1A0E34592D0E5F46C4
    content: "---\nextracts:\n# Values: Enabled, Disabled. Not Nullable. Can't have\
      \ no access, retrieved via Microsoft.DBforMySQL/servers/read\n  - name: \"CA10Z1__sslEnforcement__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10Z1__sslEnforcement__c\"\n \
      \       undeterminedIf:\n          isEmpty: \"Corrupted Data. MySQL Server SSL\
      \ Enforcement cannot be empty.\"\n# Values: TLS1_0, TLS1_1, TLS1_2, TLSEnforcementDisabled.\
      \ Not Nullable. Can't have no access, retrieved via Microsoft.DBforMySQL/servers/read\n\
      \  - name: \"CA10Z1__minimalTlsVersion__c\"\n    value: \n      FIELD:\n   \
      \     path: \"CA10Z1__minimalTlsVersion__c\"\n        undeterminedIf:\n    \
      \      isEmpty: \"Corrupted Data. MySQL Server Minimal TLS Version cannot be\
      \ empty.\"\n  - name: \"CA10Z1__deploymentMode__c\"\n    value: \n      FIELD:\n\
      \        path: \"CA10Z1__deploymentMode__c\"\n        undeterminedIf:\n    \
      \      isEmpty: \"Corrupted Data. MySQL Deployment Mode cannot be empty.\"\n\
      # Not nullable\n  - name: \"CA10Z1__configurations__c\"\n    value:\n      FIELD:\n\
      \        path: \"CA10Z1__configurations__c\"\n        returnType: BYTES\n  \
      \      undeterminedIf:\n          noAccessDelegate:\n            path: \"CA10Z1__configurations__c\"\
      \n            currentStateMessage: \"Unable to determine Server Configurations.\
      \ Possible permission issue with Microsoft.DBforPostgreSQL/servers/configurations/read\"\
      \n  - name: \"caJsonFrom__configurations__c\"\n    value: \n      JSON_FROM:\n\
      \        arg: \n          EXTRACT: \"CA10Z1__configurations__c\"\n        undeterminedIf:\n\
      \          isInvalid: \"Configurations JSON is invalid.\"\n# Not nullable \n\
      \  - name: \"CA10Z1__state__c\"\n    value: \n      FIELD:\n        path: \"\
      CA10Z1__state__c\"\n# Nullable \n  - name: \"CA10Z1__monitorCpuPercentAvg30Day__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10Z1__monitorCpuPercentAvg30Day__c\"\
      \n# Nullable \n  - name: \"CA10Z1__monitorMemoryPercentAvg30Day__c\"\n    value:\
      \ \n      FIELD:\n        path: \"CA10Z1__monitorMemoryPercentAvg30Day__c\"\n\
      # Nullable \n  - name: \"CA10Z1__monitorIoConsumptionPercentAvg30Day__c\"\n\
      \    value: \n      FIELD:\n        path: \"CA10Z1__monitorIoConsumptionPercentAvg30Day__c\"\
      \n  - name: \"CA10Z1__locationName__c\"\n    value: \n      FIELD:\n       \
      \ path: \"CA10Z1__locationName__c\"\n\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(CA10Z1__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "002",
    "expectedResult" : {
      "status" : "INAPPLICABLE",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10Z1__state__c') != 'Ready'",
      "runtimeError" : null
    }
  }, {
    "Id" : "003",
    "expectedResult" : {
      "status" : "UNDETERMINED",
      "conditionIndex" : "299",
      "conditionText" : "extract('CA10Z1__monitorCpuPercentAvg30Day__c').isEmpty() || extract('CA10Z1__monitorMemoryPercentAvg30Day__c').isEmpty() || extract('CA10Z1__monitorIoConsumptionPercentAvg30Day__c').isEmpty()",
      "runtimeError" : null
    }
  }, {
    "Id" : "004",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "399",
      "conditionText" : "extract('CA10Z1__monitorCpuPercentAvg30Day__c') < number(20.0) && extract('CA10Z1__monitorMemoryPercentAvg30Day__c') < number(40.0) && extract('CA10Z1__monitorIoConsumptionPercentAvg30Day__c') < number(20.0)",
      "runtimeError" : null
    }
  }, {
    "Id" : "005",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "400",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "006",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "400",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10Z1__CaAzureMySqlServer__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10Z1__disappearanceTime__c TIMESTAMP,
      CA10Z1__state__c STRING,
      CA10Z1__monitorCpuPercentAvg30Day__c FLOAT64,
      CA10Z1__monitorMemoryPercentAvg30Day__c FLOAT64,
      CA10Z1__monitorIoConsumptionPercentAvg30Day__c FLOAT64,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-09-17T01:22:29Z")
    },
    "Id" : "001",
    "CA10Z1__disappearanceTime__c" : new Date("2025-09-17T01:22:29Z"),
    "CA10Z1__state__c" : "Ready",
    "CA10Z1__monitorCpuPercentAvg30Day__c" : 10,
    "CA10Z1__monitorMemoryPercentAvg30Day__c" : 10,
    "CA10Z1__monitorIoConsumptionPercentAvg30Day__c" : 10
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-09-17T01:22:29Z")
    },
    "Id" : "002",
    "CA10Z1__state__c" : "Error",
    "CA10Z1__monitorCpuPercentAvg30Day__c" : 10,
    "CA10Z1__monitorMemoryPercentAvg30Day__c" : 10,
    "CA10Z1__monitorIoConsumptionPercentAvg30Day__c" : 10
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-09-17T01:22:29Z")
    },
    "Id" : "003",
    "CA10Z1__state__c" : "Ready",
    "CA10Z1__monitorCpuPercentAvg30Day__c" : null,
    "CA10Z1__monitorMemoryPercentAvg30Day__c" : null,
    "CA10Z1__monitorIoConsumptionPercentAvg30Day__c" : null
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-09-17T01:22:29Z")
    },
    "Id" : "004",
    "CA10Z1__state__c" : "Ready",
    "CA10Z1__monitorCpuPercentAvg30Day__c" : 10,
    "CA10Z1__monitorMemoryPercentAvg30Day__c" : 10,
    "CA10Z1__monitorIoConsumptionPercentAvg30Day__c" : 10
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-09-17T01:22:29Z")
    },
    "Id" : "005",
    "CA10Z1__state__c" : "Ready",
    "CA10Z1__monitorCpuPercentAvg30Day__c" : 20,
    "CA10Z1__monitorMemoryPercentAvg30Day__c" : 40,
    "CA10Z1__monitorIoConsumptionPercentAvg30Day__c" : 20
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-09-17T01:22:29Z")
    },
    "Id" : "006",
    "CA10Z1__state__c" : "Ready",
    "CA10Z1__monitorCpuPercentAvg30Day__c" : 50,
    "CA10Z1__monitorMemoryPercentAvg30Day__c" : 50,
    "CA10Z1__monitorIoConsumptionPercentAvg30Day__c" : 50
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10Z1__CaAzureMySqlServer__c(
      obj STRUCT<
          Id STRING,
          CA10Z1__disappearanceTime__c TIMESTAMP,
          CA10Z1__state__c STRING,
          CA10Z1__monitorCpuPercentAvg30Day__c FLOAT64,
          CA10Z1__monitorMemoryPercentAvg30Day__c FLOAT64,
          CA10Z1__monitorIoConsumptionPercentAvg30Day__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 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 [CA10Z1__disappearanceTime__c]: ' + obj.CA10Z1__disappearanceTime__c);
      if (obj.CA10Z1__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10Z1__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.CA10Z1__state__c; } return this.out; };
      references1.push('State [obj.CA10Z1__state__c]: ' + obj.CA10Z1__state__c);
      if (TextLib.notEqual(extract3.call(extract3), 'Ready')) {
          return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10Z1__state__c') != 'Ready'", currentStateMessage: "The server is not ready.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      function extract6() { if (!this.out) { this.out = obj.CA10Z1__monitorCpuPercentAvg30Day__c; } return this.out; };
      function extract9() { if (!this.out) { this.out = obj.CA10Z1__monitorMemoryPercentAvg30Day__c; } return this.out; };
      function extract12() { if (!this.out) { this.out = obj.CA10Z1__monitorIoConsumptionPercentAvg30Day__c; } return this.out; };
      references1.push('Monitor: CPU Percent, 30-Day [obj.CA10Z1__monitorCpuPercentAvg30Day__c]: ' + obj.CA10Z1__monitorCpuPercentAvg30Day__c);
      references1.push('Monitor: Memory Percent, 30-Day [obj.CA10Z1__monitorMemoryPercentAvg30Day__c]: ' + obj.CA10Z1__monitorMemoryPercentAvg30Day__c);
      references1.push('Monitor: IO Consumption Percent, 30-Day [obj.CA10Z1__monitorIoConsumptionPercentAvg30Day__c]: ' + obj.CA10Z1__monitorIoConsumptionPercentAvg30Day__c);
      if (IsEmptyLib.simpleIsEmpty(extract6.call(extract6)) || IsEmptyLib.simpleIsEmpty(extract9.call(extract9)) || IsEmptyLib.simpleIsEmpty(extract12.call(extract12))) {
          return {status: 'UNDETERMINED', conditionIndex: 299, conditionText: "extract('CA10Z1__monitorCpuPercentAvg30Day__c').isEmpty() || extract('CA10Z1__monitorMemoryPercentAvg30Day__c').isEmpty() || extract('CA10Z1__monitorIoConsumptionPercentAvg30Day__c').isEmpty()", currentStateMessage: "There is not enough data in the CMDB to identify if the server is underutilized.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[3], conditionIndex:[300..399]
      function extract16() { if (!this.out) { this.out = obj.CA10Z1__monitorCpuPercentAvg30Day__c; } return this.out; };
      function extract20() { if (!this.out) { this.out = obj.CA10Z1__monitorMemoryPercentAvg30Day__c; } return this.out; };
      function extract24() { if (!this.out) { this.out = obj.CA10Z1__monitorIoConsumptionPercentAvg30Day__c; } return this.out; };
      if ((extract16.call(extract16) != null && 20.0 != null && extract16.call(extract16) < 20.0) && (extract20.call(extract20) != null && 40.0 != null && extract20.call(extract20) < 40.0) && (extract24.call(extract24) != null && 20.0 != null && extract24.call(extract24) < 20.0)) {
          return {status: 'INCOMPLIANT', conditionIndex: 399, conditionText: "extract('CA10Z1__monitorCpuPercentAvg30Day__c') < number(20.0) && extract('CA10Z1__monitorMemoryPercentAvg30Day__c') < number(40.0) && extract('CA10Z1__monitorIoConsumptionPercentAvg30Day__c') < number(20.0)", currentStateMessage: "The server is underutilized with Average CPU and IO < 20%, and Memory Utilization < 40%.", currentStateReferences: references1.join('\n'), remediation: "Consider rightsizing, the server.", runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 400, conditionText: "otherwise", currentStateMessage: "The server 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.CA10Z1__disappearanceTime__c AS CA10Z1__disappearanceTime__c,
          sObject.CA10Z1__state__c AS CA10Z1__state__c,
          sObject.CA10Z1__monitorCpuPercentAvg30Day__c AS CA10Z1__monitorCpuPercentAvg30Day__c,
          sObject.CA10Z1__monitorMemoryPercentAvg30Day__c AS CA10Z1__monitorMemoryPercentAvg30Day__c,
          sObject.CA10Z1__monitorIoConsumptionPercentAvg30Day__c AS CA10Z1__monitorIoConsumptionPercentAvg30Day__c,
          process_CA10Z1__CaAzureMySqlServer__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.CA10Z1__disappearanceTime__c AS CA10Z1__disappearanceTime__c,
                  sObject.CA10Z1__state__c AS CA10Z1__state__c,
                  sObject.CA10Z1__monitorCpuPercentAvg30Day__c AS CA10Z1__monitorCpuPercentAvg30Day__c,
                  sObject.CA10Z1__monitorMemoryPercentAvg30Day__c AS CA10Z1__monitorMemoryPercentAvg30Day__c,
                  sObject.CA10Z1__monitorIoConsumptionPercentAvg30Day__c AS CA10Z1__monitorIoConsumptionPercentAvg30Day__c
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10Z1__CaAzureMySqlServer__c()) AS sObject
  ) sObject ON sObject.Id = expectedResult.Id;
