---
policy: /ce/ca/azure/databricks/diagnostic-log-delivery
logic: /ce/ca/azure/databricks/diagnostic-log-delivery/prod.logic.yaml
executionTime: 2025-12-17T01:31:04.055917083Z
generationMs: 96
executionMs: 771
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: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: CA10Z1__Azure_Diagnostic_Settings__r.has(COMPLIANT)
      actual: CA10Z1__Azure_Diagnostic_Settings__r.has(COMPLIANT)
    runtimeError: {}
  - id: '003'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: '004'
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/azure/databricks/diagnostic-log-delivery/policy.yaml
    md5Hash: D182791A3A15CC3F255A429DC174156D
    content: "---\nnames:\n  full: Azure Databricks Diagnostic Log Delivery is not\
      \ configured\n  contextual: Databricks Diagnostic Log Delivery is not configured\n\
      description: |-\n  Azure Databricks Diagnostic Logging provides insights into\
      \ system operations, \n  user activities, and security events within a Databricks\
      \ workspace. Enabling \n  diagnostic logs helps organizations:\n  \n  - Detect\
      \ security threats by logging access, job executions, and cluster activities.\n\
      \  - Ensure compliance with industry regulations such as SOC 2, HIPAA, and GDPR.\n\
      \  - Monitor operational performance and troubleshoot issues proactively.\n\
      type: COMPLIANCE_POLICY\ncategories:\n  - RELIABILITY\nframeworkMappings:\n\
      \  - \"/frameworks/cis-azure-v5.0.0/02/01/07\"\n  - \"/frameworks/cloudaware/resource-reliability/system-configuration\"\
      \n"
  - path: /ce/ca/azure/databricks/diagnostic-log-delivery/prod.logic.yaml
    md5Hash: 4C46AF91A60E2FC6CBBFFD8308476416
    content: "---\ninputType: \"CA10Z1__CaAzureDatabricksWorkspace__c\"\ntestData:\n\
      \  - file: \"test-data.json\"\nconditions:\n  - status: \"COMPLIANT\"\n    currentStateMessage:\
      \ \"Diagnostic log delivery is configured for Azure Databricks.\"\n    check:\n\
      \      RELATED_LIST_HAS:\n        status: \"COMPLIANT\"\n        relationshipName:\
      \ \"CA10Z1__Azure_Diagnostic_Settings__r\"\notherwise:\n  status: \"INCOMPLIANT\"\
      \n  currentStateMessage: \"Diagnostic log delivery is not configured for Azure\
      \ Databricks.\"\n  remediationMessage: \"Configure diagnostic log delivery.\"\
      \nrelatedLists:\n  - relationshipName: \"CA10Z1__Azure_Diagnostic_Settings__r\"\
      \n    importExtracts:\n      - file: \"/types/CA10__CaAzureDiagnosticSetting__c/object.extracts.yaml\"\
      \n    conditions: \n# Ensure that logging is enabled for the following categories:\
      \ accounts, clusters, notebook, jobs, workspace\n      - status: \"INCOMPLIANT\"\
      \n        currentStateMessage: \"Logging is not enabled for the required categories.\"\
      \n        check:\n          NOT:\n            arg:\n              AND:\n   \
      \             args:\n                  - JSON_QUERY_BOOLEAN:\n             \
      \         arg: \n                        EXTRACT: \"caJsonFrom__logsJson__c\"\
      \n                      expression: \"[? category == `accounts`].enabled | [0]\"\
      \n                      undeterminedIf: \n                        evaluationError:\
      \ \"The JSON query has failed.\"\n                        resultTypeMismatch:\
      \ \"The JSON query did not return boolean type.\"\n                  - JSON_QUERY_BOOLEAN:\n\
      \                      arg: \n                        EXTRACT: \"caJsonFrom__logsJson__c\"\
      \n                      expression: \"[? category == `clusters`].enabled | [0]\"\
      \n                      undeterminedIf: \n                        evaluationError:\
      \ \"The JSON query has failed.\"\n                        resultTypeMismatch:\
      \ \"The JSON query did not return boolean type.\"\n                  - JSON_QUERY_BOOLEAN:\n\
      \                      arg: \n                        EXTRACT: \"caJsonFrom__logsJson__c\"\
      \n                      expression: \"[? category == `notebook`].enabled | [0]\"\
      \n                      undeterminedIf: \n                        evaluationError:\
      \ \"The JSON query has failed.\"\n                        resultTypeMismatch:\
      \ \"The JSON query did not return boolean type.\"\n                  - JSON_QUERY_BOOLEAN:\n\
      \                      arg: \n                        EXTRACT: \"caJsonFrom__logsJson__c\"\
      \n                      expression: \"[? category == `jobs`].enabled | [0]\"\
      \n                      undeterminedIf: \n                        evaluationError:\
      \ \"The JSON query has failed.\"\n                        resultTypeMismatch:\
      \ \"The JSON query did not return boolean type.\"\n                  - JSON_QUERY_BOOLEAN:\n\
      \                      arg: \n                        EXTRACT: \"caJsonFrom__logsJson__c\"\
      \n                      expression: \"[? category == `workspace`].enabled |\
      \ [0]\"\n                      undeterminedIf: \n                        evaluationError:\
      \ \"The JSON query has failed.\"\n                        resultTypeMismatch:\
      \ \"The JSON query did not return boolean type.\"\n# Verify that logs are being\
      \ sent to one or more of the following destinations: Azure Log Analytics workspace,\
      \ Azure Storage Account, Azure Event Hubs\n      - status: \"INCOMPLIANT\"\n\
      \        currentStateMessage: \"Logs destination does not exist.\"\n       \
      \ remediationMessage: \"Set a destination for the logs\"\n        check:\n \
      \         AND:\n            args:\n              - IS_EMPTY:\n             \
      \     arg:\n                    EXTRACT: \"CA10__workspaceId__c\"\n        \
      \      - IS_EMPTY:\n                  arg:\n                    EXTRACT: CA10__storageAccountId__c\n\
      \              - IS_EMPTY:\n                  arg:\n                    EXTRACT:\
      \ CA10__eventHubAuthorizationRuleId__c\n    otherwise:\n      status: \"COMPLIANT\"\
      \n      currentStateMessage: \"Diagnostic Settings are configured properly.\"\
      \n"
  - path: /ce/ca/azure/databricks/diagnostic-log-delivery/test-data.json
    md5Hash: 9430D38BB4C36F2C05EE48899F2F6878
    content: |
      [
        {
          "expectedResult": {
            "status": "DISAPPEARED",
            "conditionIndex": "99",
            "conditionText": "isDisappeared(CA10Z1__disappearanceTime__c)",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-11-18T09:00:42Z" },
          "CA10Z1__disappearanceTime__c": "2025-11-13T16:22:07Z",
          "Id": "001",
          "CA10Z1__Azure_Diagnostic_Settings__r": [
            {
              "CA10__disappearanceTime__c": "2025-11-13T15:16:15Z",
              "CA10__logsJson__c": "[{\"categoryGroup\":\"allLogs\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":false,\"days\":0}}]",
              "CA10__workspaceId__c": "",
              "CA10__storageAccountId__c": "",
              "CA10__eventHubAuthorizationRuleId__c": "/subscriptions/1/resourcegroups/1/providers/1/001",
              "CA10Z1__databricksWorkspace__c": "001",
              "Id": "ads001",
              "RecordTypeId": "RecordTypeId",
              "RecordType": { "Id": "RecordTypeId" }
            }
          ]
        },
        {
          "expectedResult": {
            "status": "COMPLIANT",
            "conditionIndex": "199",
            "conditionText": "CA10Z1__Azure_Diagnostic_Settings__r.has(COMPLIANT)",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-11-18T09:00:42Z" },
          "CA10Z1__disappearanceTime__c": null,
          "Id": "002",
          "CA10Z1__Azure_Diagnostic_Settings__r": [
            {
              "CA10__disappearanceTime__c": null,
              "CA10__logsJson__c": "[{\"category\":\"dbfs\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"clusters\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"accounts\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"jobs\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"notebook\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"ssh\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"workspace\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"secrets\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"sqlPermissions\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"instancePools\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"sqlanalytics\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"genie\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"globalInitScripts\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"iamRole\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"mlflowExperiment\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"featureStore\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"RemoteHistoryService\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"mlflowAcledArtifact\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"databrickssql\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"deltaPipelines\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"modelRegistry\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"repos\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"unityCatalog\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"gitCredentials\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"webTerminal\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"serverlessRealTimeInference\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"clusterLibraries\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"partnerHub\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"clamAVScan\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"capsule8Dataplane\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"BrickStoreHttpGateway\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"Dashboards\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"CloudStorageMetadata\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"PredictiveOptimization\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"DataMonitoring\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"Ingestion\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"MarketplaceConsumer\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"LineageTracking\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"Apps\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"ClusterPolicies\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"DataRooms\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"Groups\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"MarketplaceProvider\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"OnlineTables\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"RBAC\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"RFA\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"VectorSearch\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"WebhookNotifications\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"WorkspaceFiles\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"Files\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"LakeviewConfig\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"BudgetPolicyCentral\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"Filesystem\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}}]",
              "CA10__workspaceId__c": "",
              "CA10__storageAccountId__c": "/subscriptions/1/resourcegroups/1/providers/1/002",
              "CA10__eventHubAuthorizationRuleId__c": "",
              "CA10Z1__databricksWorkspace__c": "002",
              "Id": "ads002",
              "RecordTypeId": "RecordTypeId",
              "RecordType": { "Id": "RecordTypeId" }
            }
          ]
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-11-18T09:00:42Z" },
          "CA10Z1__disappearanceTime__c": null,
          "Id": "003",
          "CA10Z1__Azure_Diagnostic_Settings__r": [
            {
              "CA10__disappearanceTime__c": null,
              "CA10__logsJson__c": "[{\"category\":\"dbfs\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"clusters\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"accounts\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"jobs\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"notebook\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"ssh\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"workspace\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"secrets\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"sqlPermissions\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"instancePools\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"sqlanalytics\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"genie\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"globalInitScripts\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"iamRole\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"mlflowExperiment\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"featureStore\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"RemoteHistoryService\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"mlflowAcledArtifact\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"databrickssql\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"deltaPipelines\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"modelRegistry\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"repos\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"unityCatalog\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"gitCredentials\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"webTerminal\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"serverlessRealTimeInference\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"clusterLibraries\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"partnerHub\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"clamAVScan\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"capsule8Dataplane\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"BrickStoreHttpGateway\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"Dashboards\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"CloudStorageMetadata\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"PredictiveOptimization\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"DataMonitoring\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"Ingestion\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"MarketplaceConsumer\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"LineageTracking\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"Apps\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"ClusterPolicies\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"DataRooms\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"Groups\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"MarketplaceProvider\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"OnlineTables\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"RBAC\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"RFA\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"VectorSearch\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"WebhookNotifications\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"WorkspaceFiles\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"Files\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"LakeviewConfig\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"BudgetPolicyCentral\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"Filesystem\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}}]",
              "CA10__workspaceId__c": "",
              "CA10__storageAccountId__c": "/subscriptions/1/resourcegroups/1/providers/1/003",
              "CA10__eventHubAuthorizationRuleId__c": "",
              "CA10Z1__databricksWorkspace__c": "003",
              "Id": "ads003",
              "RecordTypeId": "RecordTypeId",
              "RecordType": { "Id": "RecordTypeId" }
            }
          ]
        },
        {
          "expectedResult": {
            "status": "INCOMPLIANT",
            "conditionIndex": "200",
            "conditionText": "otherwise",
            "runtimeError": null
          },
          "context": { "snapshotTime": "2025-11-18T09:00:42Z" },
          "CA10Z1__disappearanceTime__c": null,
          "Id": "004",
          "CA10Z1__Azure_Diagnostic_Settings__r": []
        }
      ]
  - path: /types/CA10__CaAzureDiagnosticSetting__c/object.extracts.yaml
    md5Hash: 4AADFEBE59E43127A2529B2F0DB31297
    content: "---\nextracts:\n# Not Nullable. Can't have no access, retrieved via\
      \ Microsoft.Insights/diagnosticSettings/read\n  - name: \"CA10__logsJson__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__logsJson__c\"\n        returnType:\
      \ BYTES\n        undeterminedIf:\n          isEmpty: \"Corrupted Data. Diagnostic\
      \ Setting Logs JSON cannot be empty.\"\n  - name: \"caJsonFrom__logsJson__c\"\
      \n    value: \n      JSON_FROM:\n        arg: \n          EXTRACT: \"CA10__logsJson__c\"\
      \n        undeterminedIf:\n          isInvalid: \"Logs JSON is invalid.\"\n\
      # Nullable. Azure Log Analytics workspace\n  - name: \"CA10__workspaceId__c\"\
      \n    value: \n      FIELD:\n        path: \"CA10__workspaceId__c\"\n# Nullable.\
      \ Azure Storage Account\n  - name: \"CA10__storageAccountId__c\"\n    value:\
      \ \n      FIELD:\n        path: \"CA10__storageAccountId__c\"\n# Nullable. Azure\
      \ Event Hubs\n  - name: \"CA10__eventHubAuthorizationRuleId__c\"\n    value:\
      \ \n      FIELD:\n        path: \"CA10__eventHubAuthorizationRuleId__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(CA10Z1__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "002",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "CA10Z1__Azure_Diagnostic_Settings__r.has(COMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "003",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "004",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10Z1__CaAzureDatabricksWorkspace__c()
  RETURNS ARRAY<STRUCT<
      CA10Z1__disappearanceTime__c TIMESTAMP,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-11-18T09:00:42Z")
    },
    "CA10Z1__disappearanceTime__c" : new Date("2025-11-13T16:22:07Z"),
    "Id" : "001"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-11-18T09:00:42Z")
    },
    "Id" : "002"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-11-18T09:00:42Z")
    },
    "Id" : "003"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-11-18T09:00:42Z")
    },
    "Id" : "004"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAzureDiagnosticSetting__c()
  RETURNS ARRAY<STRUCT<
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__logsJson__c STRING,
      CA10__workspaceId__c STRING,
      CA10__storageAccountId__c STRING,
      CA10__eventHubAuthorizationRuleId__c STRING,
      CA10Z1__databricksWorkspace__c STRING,
      Id STRING,
      RecordTypeId STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2025-11-18T09:00:42Z")
    },
    "CA10__disappearanceTime__c" : new Date("2025-11-13T15:16:15Z"),
    "CA10__logsJson__c" : "[{\"categoryGroup\":\"allLogs\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":false,\"days\":0}}]",
    "CA10__workspaceId__c" : "",
    "CA10__storageAccountId__c" : "",
    "CA10__eventHubAuthorizationRuleId__c" : "/subscriptions/1/resourcegroups/1/providers/1/001",
    "CA10Z1__databricksWorkspace__c" : "001",
    "Id" : "ads001",
    "RecordTypeId" : "RecordTypeId"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-11-18T09:00:42Z")
    },
    "CA10__logsJson__c" : "[{\"category\":\"dbfs\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"clusters\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"accounts\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"jobs\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"notebook\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"ssh\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"workspace\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"secrets\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"sqlPermissions\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"instancePools\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"sqlanalytics\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"genie\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"globalInitScripts\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"iamRole\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"mlflowExperiment\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"featureStore\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"RemoteHistoryService\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"mlflowAcledArtifact\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"databrickssql\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"deltaPipelines\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"modelRegistry\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"repos\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"unityCatalog\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"gitCredentials\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"webTerminal\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"serverlessRealTimeInference\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"clusterLibraries\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"partnerHub\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"clamAVScan\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"capsule8Dataplane\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"BrickStoreHttpGateway\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"Dashboards\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"CloudStorageMetadata\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"PredictiveOptimization\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"DataMonitoring\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"Ingestion\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"MarketplaceConsumer\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"LineageTracking\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":true,\"days\":3}},{\"category\":\"Apps\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"ClusterPolicies\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"DataRooms\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"Groups\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"MarketplaceProvider\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"OnlineTables\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"RBAC\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"RFA\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"VectorSearch\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"WebhookNotifications\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"WorkspaceFiles\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"Files\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"LakeviewConfig\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"BudgetPolicyCentral\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"Filesystem\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}}]",
    "CA10__workspaceId__c" : "",
    "CA10__storageAccountId__c" : "/subscriptions/1/resourcegroups/1/providers/1/002",
    "CA10__eventHubAuthorizationRuleId__c" : "",
    "CA10Z1__databricksWorkspace__c" : "002",
    "Id" : "ads002",
    "RecordTypeId" : "RecordTypeId"
  }, {
    "context" : {
      "snapshotTime" : new Date("2025-11-18T09:00:42Z")
    },
    "CA10__logsJson__c" : "[{\"category\":\"dbfs\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"clusters\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"accounts\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"jobs\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"notebook\",\"enabled\":true,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"ssh\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"workspace\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"secrets\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"sqlPermissions\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"instancePools\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"sqlanalytics\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"genie\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"globalInitScripts\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"iamRole\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"mlflowExperiment\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"featureStore\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"RemoteHistoryService\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"mlflowAcledArtifact\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"databrickssql\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"deltaPipelines\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"modelRegistry\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"repos\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"unityCatalog\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"gitCredentials\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"webTerminal\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"serverlessRealTimeInference\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"clusterLibraries\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"partnerHub\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"clamAVScan\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"capsule8Dataplane\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"BrickStoreHttpGateway\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"Dashboards\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"CloudStorageMetadata\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"PredictiveOptimization\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"DataMonitoring\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"Ingestion\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"MarketplaceConsumer\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"LineageTracking\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"Apps\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"ClusterPolicies\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"DataRooms\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"Groups\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"MarketplaceProvider\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"OnlineTables\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"RBAC\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"RFA\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"VectorSearch\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"WebhookNotifications\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"WorkspaceFiles\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"Files\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"LakeviewConfig\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"BudgetPolicyCentral\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}},{\"category\":\"Filesystem\",\"enabled\":false,\"retentionPolicy\":{\"enabled\":false,\"days\":0}}]",
    "CA10__workspaceId__c" : "",
    "CA10__storageAccountId__c" : "/subscriptions/1/resourcegroups/1/providers/1/003",
    "CA10__eventHubAuthorizationRuleId__c" : "",
    "CA10Z1__databricksWorkspace__c" : "003",
    "Id" : "ads003",
    "RecordTypeId" : "RecordTypeId"
  } ];
  """;

  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-11-18T09:00:42Z")
    },
    "Id" : "RecordTypeId"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10Z1__CaAzureDatabricksWorkspace__c(
      obj STRUCT<
          CA10Z1__disappearanceTime__c TIMESTAMP,
          Id STRING,
          CA10Z1__Azure_Diagnostic_Settings__r ARRAY<STRUCT<
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__logsJson__c STRING,
              CA10__workspaceId__c STRING,
              CA10__storageAccountId__c STRING,
              CA10__eventHubAuthorizationRuleId__c STRING,
              CA10Z1__databricksWorkspace__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 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};
      }
      var count_CA10Z1__Azure_Diagnostic_Settings__r_COMPLIANT2 = 0;
      if (obj.CA10Z1__Azure_Diagnostic_Settings__r != null) {
          for (var i3 = 0; i3 < obj.CA10Z1__Azure_Diagnostic_Settings__r.length; i3++) {
              if (typeof(obj.CA10Z1__Azure_Diagnostic_Settings__r[i3].status) !== 'undefined') {
                  if (obj.CA10Z1__Azure_Diagnostic_Settings__r[i3].status == 'COMPLIANT') {
                      count_CA10Z1__Azure_Diagnostic_Settings__r_COMPLIANT2 += obj.CA10Z1__Azure_Diagnostic_Settings__r[i3].count;
                  }
              } else  {
                  if (obj.CA10Z1__Azure_Diagnostic_Settings__r[i3].result.status == 'COMPLIANT') {
                      count_CA10Z1__Azure_Diagnostic_Settings__r_COMPLIANT2 += 1;
                  }
              }
          }
      }
      // condition[1], conditionIndex:[100..199]
      references1.push('Related list [CA10Z1__Azure_Diagnostic_Settings__r] ' + (count_CA10Z1__Azure_Diagnostic_Settings__r_COMPLIANT2 > 0 ? 'has' : 'does not have') + ' objects in COMPLIANT status');
      if (count_CA10Z1__Azure_Diagnostic_Settings__r_COMPLIANT2 > 0) {
          return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "CA10Z1__Azure_Diagnostic_Settings__r.has(COMPLIANT)", currentStateMessage: "Diagnostic log delivery is configured for Azure Databricks.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'INCOMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "Diagnostic log delivery is not configured for Azure Databricks.", currentStateReferences: references1.join('\n'), remediation: "Configure diagnostic log delivery.", runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10Z1__Azure_Diagnostic_Settings__r(
      obj STRUCT<
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__logsJson__c STRING,
          CA10__workspaceId__c STRING,
          CA10__storageAccountId__c STRING,
          CA10__eventHubAuthorizationRuleId__c STRING,
          CA10Z1__databricksWorkspace__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
  OPTIONS (library=['gs://compliance-platform-public/jmespath.min.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 BytesLib = new function () {
      this.normalize = function(arg) {
          return arg == null ? '' : arg;
      };
      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 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 jsonQueryChecked2() {
          var input = extract4.call(extract4);
          var out;
          try {
              out = jmespath.search(input, '[? category == `accounts`].enabled | [0]');
          if (out != null && typeof out != 'boolean') {
              throw new Error("UNDETERMINED condition:103", {cause: {status: 'UNDETERMINED', conditionIndex: 103, conditionText: "extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `accounts`].enabled | [0]').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return boolean type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:104", {cause: {status: 'UNDETERMINED', conditionIndex: 104, conditionText: "extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `accounts`].enabled | [0]').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function jsonChecked5() {
          var input = extract7.call(extract7);
          input = TextLib.isEmpty(input) ? null : input;
          var out;
          try {
              out = JSON.parse(input);
          } catch (e) {
              throw new Error("UNDETERMINED condition:102", {cause: {status: 'UNDETERMINED', conditionIndex: 102, conditionText: "extract('CA10__logsJson__c').asJson().isInvalid()", currentStateMessage: "Logs JSON is invalid.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function fieldChecked8() {
          if (BytesLib.isEmpty(obj.CA10__logsJson__c)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10__logsJson__c.isEmpty()", currentStateMessage: "Corrupted Data. Diagnostic Setting Logs JSON cannot be empty.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10__logsJson__c;
      }
      function extract7() { if (!this.out) { this.out = fieldChecked8(); } return this.out; };
      function extract4() { if (!this.out) { this.out = jsonChecked5(); } return this.out; };
      function jsonQueryChecked9() {
          var input = extract4.call(extract4);
          var out;
          try {
              out = jmespath.search(input, '[? category == `clusters`].enabled | [0]');
          if (out != null && typeof out != 'boolean') {
              throw new Error("UNDETERMINED condition:105", {cause: {status: 'UNDETERMINED', conditionIndex: 105, conditionText: "extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `clusters`].enabled | [0]').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return boolean type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:106", {cause: {status: 'UNDETERMINED', conditionIndex: 106, conditionText: "extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `clusters`].enabled | [0]').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function jsonQueryChecked11() {
          var input = extract4.call(extract4);
          var out;
          try {
              out = jmespath.search(input, '[? category == `notebook`].enabled | [0]');
          if (out != null && typeof out != 'boolean') {
              throw new Error("UNDETERMINED condition:107", {cause: {status: 'UNDETERMINED', conditionIndex: 107, conditionText: "extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `notebook`].enabled | [0]').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return boolean type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:108", {cause: {status: 'UNDETERMINED', conditionIndex: 108, conditionText: "extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `notebook`].enabled | [0]').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function jsonQueryChecked13() {
          var input = extract4.call(extract4);
          var out;
          try {
              out = jmespath.search(input, '[? category == `jobs`].enabled | [0]');
          if (out != null && typeof out != 'boolean') {
              throw new Error("UNDETERMINED condition:109", {cause: {status: 'UNDETERMINED', conditionIndex: 109, conditionText: "extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `jobs`].enabled | [0]').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return boolean type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:110", {cause: {status: 'UNDETERMINED', conditionIndex: 110, conditionText: "extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `jobs`].enabled | [0]').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      function jsonQueryChecked15() {
          var input = extract4.call(extract4);
          var out;
          try {
              out = jmespath.search(input, '[? category == `workspace`].enabled | [0]');
          if (out != null && typeof out != 'boolean') {
              throw new Error("UNDETERMINED condition:111", {cause: {status: 'UNDETERMINED', conditionIndex: 111, conditionText: "extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `workspace`].enabled | [0]').isResultTypeMismatch()", currentStateMessage: "The JSON query did not return boolean type.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          } catch (e) {
              throw new Error("UNDETERMINED condition:112", {cause: {status: 'UNDETERMINED', conditionIndex: 112, conditionText: "extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `workspace`].enabled | [0]').isEvaluationFailed()", currentStateMessage: "The JSON query has failed.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: e.message}});
          }
          return out;
      }
      references1.push('Logs JSON [obj.CA10__logsJson__c]: ' + obj.CA10__logsJson__c);
      try {
          if (!(jsonQueryChecked2() && jsonQueryChecked9() && jsonQueryChecked11() && jsonQueryChecked13() && jsonQueryChecked15())) {
              return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "not(extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `accounts`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `clusters`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `notebook`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `jobs`].enabled | [0]') && extract('caJsonFrom__logsJson__c').jsonQueryText('[? category == `workspace`].enabled | [0]'))", currentStateMessage: "Logging is not enabled for the required categories.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      // condition[2], conditionIndex:[200..299]
      function extract18() { if (!this.out) { this.out = obj.CA10__workspaceId__c; } return this.out; };
      function extract21() { if (!this.out) { this.out = obj.CA10__storageAccountId__c; } return this.out; };
      function extract24() { if (!this.out) { this.out = obj.CA10__eventHubAuthorizationRuleId__c; } return this.out; };
      references1.push('Workspace ID [obj.CA10__workspaceId__c]: ' + obj.CA10__workspaceId__c);
      references1.push('Storage Account ID [obj.CA10__storageAccountId__c]: ' + obj.CA10__storageAccountId__c);
      references1.push('Event Hub Authorizartion Rule ID [obj.CA10__eventHubAuthorizationRuleId__c]: ' + obj.CA10__eventHubAuthorizationRuleId__c);
      if (TextLib.isEmpty(extract18.call(extract18)) && TextLib.isEmpty(extract21.call(extract21)) && TextLib.isEmpty(extract24.call(extract24))) {
          return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__workspaceId__c').isEmpty() && extract('CA10__storageAccountId__c').isEmpty() && extract('CA10__eventHubAuthorizationRuleId__c').isEmpty()", currentStateMessage: "Logs destination does not exist.", currentStateReferences: references1.join('\n'), remediation: "Set a destination for the logs", runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "Diagnostic Settings are configured properly.", 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.CA10Z1__disappearanceTime__c AS CA10Z1__disappearanceTime__c,
          sObject.Id AS Id,
          `CA10Z1__Azure_Diagnostic_Settings__r`.arr AS CA10Z1__Azure_Diagnostic_Settings__r,
          process_CA10Z1__CaAzureDatabricksWorkspace__c(
              STRUCT(
                  sObject.CA10Z1__disappearanceTime__c AS CA10Z1__disappearanceTime__c,
                  sObject.Id AS Id,
                  `CA10Z1__Azure_Diagnostic_Settings__r`.arr AS CA10Z1__Azure_Diagnostic_Settings__r
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10Z1__CaAzureDatabricksWorkspace__c()) AS sObject
      LEFT JOIN (
          SELECT
              sObject.CA10Z1__databricksWorkspace__c,
              ARRAY_AGG(
                  STRUCT(
                      sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                      sObject.CA10__logsJson__c AS CA10__logsJson__c,
                      sObject.CA10__workspaceId__c AS CA10__workspaceId__c,
                      sObject.CA10__storageAccountId__c AS CA10__storageAccountId__c,
                      sObject.CA10__eventHubAuthorizationRuleId__c AS CA10__eventHubAuthorizationRuleId__c,
                      sObject.CA10Z1__databricksWorkspace__c AS CA10Z1__databricksWorkspace__c,
                      sObject.Id AS Id,
                      sObject.RecordTypeId AS RecordTypeId,
                      STRUCT (
                          `RecordType`.Id AS Id
                      ) AS RecordType,
                      process_CA10Z1__Azure_Diagnostic_Settings__r(
                          STRUCT(
                              sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                              sObject.CA10__logsJson__c AS CA10__logsJson__c,
                              sObject.CA10__workspaceId__c AS CA10__workspaceId__c,
                              sObject.CA10__storageAccountId__c AS CA10__storageAccountId__c,
                              sObject.CA10__eventHubAuthorizationRuleId__c AS CA10__eventHubAuthorizationRuleId__c,
                              sObject.CA10Z1__databricksWorkspace__c AS CA10Z1__databricksWorkspace__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_CA10__CaAzureDiagnosticSetting__c()) AS sObject
          LEFT JOIN UNNEST(mock_RecordType()) AS `RecordType`
              ON sObject.RecordTypeId = `RecordType`.Id
          GROUP BY sObject.CA10Z1__databricksWorkspace__c
      ) AS `CA10Z1__Azure_Diagnostic_Settings__r`
          ON sObject.Id = `CA10Z1__Azure_Diagnostic_Settings__r`.CA10Z1__databricksWorkspace__c
  ) sObject ON sObject.Id = expectedResult.Id;
