{
  "data": {
    "basis": "RECOMPILED",
    "compilationTrace": {
      "events": [
        {
          "confidence": "EXACT",
          "decision": "NORMALIZED",
          "details": {
            "requestedFieldCount": 3
          },
          "event": "SEMANTIC_DSL_NORMALIZED",
          "observedAt": "2026-10-20T05:19:56.952398900Z",
          "reasonCode": "DSL_NORMALIZED",
          "sequence": 1,
          "stage": "NORMALIZATION",
          "status": "EVALUATED"
        },
        {
          "confidence": "EXACT",
          "decision": "RAW",
          "details": {},
          "event": "PRE_AGGREGATION_ROUTING",
          "observedAt": "2026-10-20T05:19:56.954403Z",
          "reasonCode": "PREAGG_NOT_CONFIGURED",
          "sequence": 2,
          "stage": "MATERIALIZATION",
          "status": "EVALUATED"
        },
        {
          "confidence": "OBSERVED",
          "decision": "RAW",
          "details": {
            "parameterCount": 2,
            "preAggApplied": false,
            "sourceOfTruth": "QueryExecutionContext.sql",
            "sqlChanged": false
          },
          "event": "FINAL_QUERY_EXECUTION_CONTEXT_CAPTURED",
          "observedAt": "2026-10-20T05:19:56.954403Z",
          "reasonCode": "PREAGG_NOT_CONFIGURED",
          "sequence": 3,
          "stage": "SQL",
          "status": "EVALUATED"
        }
      ],
      "fieldResolution": [
        {
          "confidence": "OBSERVED",
          "requested": "amount",
          "resolved": "amount"
        },
        {
          "confidence": "OBSERVED",
          "requested": "bills",
          "resolved": "bills"
        },
        {
          "confidence": "EXACT",
          "requested": "averageAmount",
          "resolved": "averageAmount",
          "tableField": "averageAmount",
          "tableModel": "ChinookInvoiceModel"
        }
      ],
      "normalizedConditions": [
        {
          "confidence": "EXACT",
          "field": "invoiceDate",
          "operator": "[)",
          "origin": "USER_SLICE",
          "path": "slice[0]",
          "redactedValue": "***",
          "valueType": "LIST<String>"
        }
      ],
      "normalizedDsl": {
        "autoFixDimCaption": false,
        "autoGroupBy": true,
        "calculatedFields": [
          {
            "caption": "平均账单金额",
            "description": "当前筛选与分组范围的账单总金额除以账单数；无账单时为空，不累计或简单平均分组均额。样例原始单位，币种未指定。",
            "expression": "sum(invoiceAmount) / nullif(count(invoiceId), 0)",
            "name": "averageAmount",
            "type": "MONEY"
          },
          {
            "agg": "SUM",
            "expression": "sum(invoiceAmount)",
            "name": "amount"
          },
          {
            "agg": "COUNT",
            "expression": "count(invoiceId)",
            "name": "bills"
          }
        ],
        "columns": [
          "amount",
          "bills",
          "averageAmount"
        ],
        "distinct": false,
        "groupBy": [
          {
            "agg": "SUM",
            "field": "amount"
          },
          {
            "agg": "COUNT",
            "field": "bills"
          },
          {
            "agg": "null",
            "field": "averageAmount"
          }
        ],
        "optimizeAggSqlEnabled": true,
        "postAggregateCalculations": [],
        "queryModel": "ChinookInvoiceQueryModel",
        "returnTotal": false,
        "slice": [
          {
            "$and": [],
            "$or": [],
            "field": "invoiceDate",
            "maxDepth": 0,
            "op": "[)",
            "value": "***"
          }
        ],
        "strictColumns": true,
        "withSubtotals": false
      },
      "originalDsl": {
        "captionMatchMode": "EXACT",
        "columns": [
          "sum(invoiceAmount) as amount",
          "count(invoiceId) as bills",
          "averageAmount"
        ],
        "distinct": false,
        "limit": 2,
        "mismatchHandleStrategy": "ABORT",
        "pivotMode": false,
        "returnTotal": false,
        "slice": [
          {
            "field": "invoiceDate",
            "op": "[)",
            "value": "***"
          }
        ],
        "start": 0,
        "withSubtotals": false
      },
      "stagePlan": {
        "dialect": "sqlite",
        "fallbacks": [],
        "preAggOptimizationPolicy": "optimizer-allowed",
        "renderStrategy": "single",
        "returnTotalStrategy": "disabled",
        "stages": [
          {
            "filterAliases": [
              "invoiceDate"
            ],
            "id": "row",
            "inputAliases": [],
            "orderAliases": [],
            "outputAliases": [
              "invoiceDate",
              "amount",
              "bills",
              "averageAmount"
            ],
            "parameterCount": 2,
            "requiresSqlBoundary": false,
            "sqlAlias": "base",
            "type": "ROW_STAGE"
          },
          {
            "filterAliases": [],
            "id": "agg",
            "inputAliases": [
              "invoiceDate",
              "amount",
              "bills",
              "averageAmount"
            ],
            "orderAliases": [],
            "outputAliases": [
              "amount",
              "bills",
              "averageAmount"
            ],
            "parameterCount": 0,
            "requiresSqlBoundary": false,
            "sqlAlias": "base",
            "type": "AGGREGATE_STAGE"
          },
          {
            "filterAliases": [],
            "id": "final",
            "inputAliases": [
              "amount",
              "bills",
              "averageAmount"
            ],
            "orderAliases": [],
            "outputAliases": [
              "amount",
              "bills",
              "averageAmount"
            ],
            "parameterCount": 0,
            "requiresSqlBoundary": false,
            "sqlAlias": "final",
            "type": "FINAL_STAGE"
          }
        ],
        "unsupported": [],
        "version": "v1"
      }
    },
    "definitionTrace": {
      "fields": [
        {
          "dataType": "INTEGER",
          "fieldType": "property",
          "lineage": [
            {
              "confidence": "EXACT",
              "from": "ChinookInvoiceQueryModel.invoiceId",
              "reasonCode": "QM_TO_TM_MODEL_STRUCTURE",
              "to": "ChinookInvoiceModel.invoiceId"
            },
            {
              "column": "InvoiceId",
              "confidence": "EXACT",
              "from": "ChinookInvoiceModel.invoiceId",
              "reasonCode": "TABLE_COLUMN_MODEL_STRUCTURE",
              "relation": "Invoice",
              "to": "Invoice.InvoiceId"
            }
          ],
          "queryField": "ChinookInvoiceQueryModel.invoiceId",
          "references": [],
          "tableField": "invoiceId",
          "tableModel": "ChinookInvoiceModel"
        },
        {
          "dataType": "DATETIME",
          "fieldType": "property",
          "lineage": [
            {
              "confidence": "EXACT",
              "from": "ChinookInvoiceQueryModel.invoiceDate",
              "reasonCode": "QM_TO_TM_MODEL_STRUCTURE",
              "to": "ChinookInvoiceModel.invoiceDate"
            },
            {
              "column": "InvoiceDate",
              "confidence": "EXACT",
              "from": "ChinookInvoiceModel.invoiceDate",
              "reasonCode": "TABLE_COLUMN_MODEL_STRUCTURE",
              "relation": "Invoice",
              "to": "Invoice.InvoiceDate"
            }
          ],
          "queryField": "ChinookInvoiceQueryModel.invoiceDate",
          "references": [],
          "tableField": "invoiceDate",
          "tableModel": "ChinookInvoiceModel"
        },
        {
          "dataType": "STRING",
          "fieldType": "property",
          "lineage": [
            {
              "confidence": "EXACT",
              "from": "ChinookInvoiceQueryModel.billingCountry",
              "reasonCode": "QM_TO_TM_MODEL_STRUCTURE",
              "to": "ChinookInvoiceModel.billingCountry"
            },
            {
              "column": "BillingCountry",
              "confidence": "EXACT",
              "from": "ChinookInvoiceModel.billingCountry",
              "reasonCode": "TABLE_COLUMN_MODEL_STRUCTURE",
              "relation": "Invoice",
              "to": "Invoice.BillingCountry"
            }
          ],
          "queryField": "ChinookInvoiceQueryModel.billingCountry",
          "references": [],
          "tableField": "billingCountry",
          "tableModel": "ChinookInvoiceModel"
        },
        {
          "dataType": "INTEGER",
          "fieldType": "property",
          "lineage": [
            {
              "confidence": "EXACT",
              "from": "ChinookInvoiceQueryModel.customerId",
              "reasonCode": "QM_TO_TM_MODEL_STRUCTURE",
              "to": "ChinookInvoiceModel.customerId"
            },
            {
              "column": "CustomerId",
              "confidence": "EXACT",
              "from": "ChinookInvoiceModel.customerId",
              "reasonCode": "TABLE_COLUMN_MODEL_STRUCTURE",
              "relation": "Invoice",
              "to": "Invoice.CustomerId"
            }
          ],
          "queryField": "ChinookInvoiceQueryModel.customerId",
          "references": [],
          "tableField": "customerId",
          "tableModel": "ChinookInvoiceModel"
        },
        {
          "dataType": "STRING",
          "fieldType": "property",
          "lineage": [
            {
              "confidence": "EXACT",
              "from": "ChinookInvoiceQueryModel.customer$fullName",
              "reasonCode": "QM_TO_TM_MODEL_STRUCTURE",
              "to": "unresolved-tm.customer$id"
            },
            {
              "column": "FirstName",
              "confidence": "EXACT",
              "from": "unresolved-tm.customer$id",
              "reasonCode": "TABLE_COLUMN_MODEL_STRUCTURE",
              "relation": "Customer",
              "to": "Customer.FirstName"
            }
          ],
          "queryField": "ChinookInvoiceQueryModel.customer$fullName",
          "references": [],
          "tableField": "customer$id"
        },
        {
          "dataType": "STRING",
          "fieldType": "property",
          "lineage": [
            {
              "confidence": "EXACT",
              "from": "ChinookInvoiceQueryModel.customer$country",
              "reasonCode": "QM_TO_TM_MODEL_STRUCTURE",
              "to": "unresolved-tm.customer$id"
            },
            {
              "column": "Country",
              "confidence": "EXACT",
              "from": "unresolved-tm.customer$id",
              "reasonCode": "TABLE_COLUMN_MODEL_STRUCTURE",
              "relation": "Customer",
              "to": "Customer.Country"
            }
          ],
          "queryField": "ChinookInvoiceQueryModel.customer$country",
          "references": [],
          "tableField": "customer$id"
        },
        {
          "aggregationFormula": "SUM(Total)",
          "dataType": "MONEY",
          "fieldType": "measure",
          "lineage": [
            {
              "confidence": "EXACT",
              "from": "ChinookInvoiceQueryModel.invoiceAmount",
              "reasonCode": "QM_TO_TM_MODEL_STRUCTURE",
              "to": "ChinookInvoiceModel.invoiceAmount"
            },
            {
              "confidence": "EXACT",
              "expression": "SUM(Total)",
              "from": "ChinookInvoiceModel.invoiceAmount",
              "reasonCode": "AGGREGATION_MODEL_STRUCTURE",
              "to": "SUM(Total)"
            },
            {
              "column": "Total",
              "confidence": "EXACT",
              "from": "ChinookInvoiceModel.invoiceAmount",
              "reasonCode": "TABLE_COLUMN_MODEL_STRUCTURE",
              "relation": "Invoice",
              "to": "Invoice.Total"
            }
          ],
          "queryField": "ChinookInvoiceQueryModel.invoiceAmount",
          "references": [],
          "tableField": "invoiceAmount",
          "tableModel": "ChinookInvoiceModel"
        },
        {
          "aggregationFormula": "COUNT(InvoiceId)",
          "dataType": "INTEGER",
          "fieldType": "measure",
          "lineage": [
            {
              "confidence": "EXACT",
              "from": "ChinookInvoiceQueryModel.invoiceCount",
              "reasonCode": "QM_TO_TM_MODEL_STRUCTURE",
              "to": "ChinookInvoiceModel.invoiceCount"
            },
            {
              "confidence": "EXACT",
              "expression": "COUNT(InvoiceId)",
              "from": "ChinookInvoiceModel.invoiceCount",
              "reasonCode": "AGGREGATION_MODEL_STRUCTURE",
              "to": "COUNT(InvoiceId)"
            },
            {
              "column": "InvoiceId",
              "confidence": "EXACT",
              "from": "ChinookInvoiceModel.invoiceCount",
              "reasonCode": "TABLE_COLUMN_MODEL_STRUCTURE",
              "relation": "Invoice",
              "to": "Invoice.InvoiceId"
            }
          ],
          "queryField": "ChinookInvoiceQueryModel.invoiceCount",
          "references": [],
          "tableField": "invoiceCount",
          "tableModel": "ChinookInvoiceModel"
        },
        {
          "aggregationFormula": "sum(invoiceAmount) / nullif(count(invoiceId), 0)",
          "dataType": "MONEY",
          "fieldType": "calculated",
          "lineage": [
            {
              "confidence": "DECLARED",
              "expression": "sum(invoiceAmount) / nullif(count(invoiceId), 0)",
              "from": "ChinookInvoiceQueryModel.averageAmount",
              "reasonCode": "CALCULATED_FIELD_DECLARATION",
              "to": "calculated:averageAmount"
            }
          ],
          "queryField": "ChinookInvoiceQueryModel.averageAmount",
          "references": [
            "invoiceAmount",
            "invoiceId"
          ],
          "tableField": "averageAmount",
          "tableModel": "ChinookInvoiceModel"
        }
      ],
      "joins": [
        {
          "confidence": "EXACT",
          "foreignKey": "CustomerId",
          "fromModel": "ChinookInvoiceModel",
          "joinType": "LEFT",
          "reasonCode": "JOIN_FOREIGN_KEY_MODEL_STRUCTURE"
        }
      ],
      "model": {
        "dependencies": [
          {
            "kind": "TABLE",
            "name": "ChinookInvoiceModel"
          }
        ],
        "kind": "QUERY",
        "name": "ChinookInvoiceQueryModel",
        "namespace": "chinook",
        "revision": "source:1ce0e063-902b-4150-ab27-d627a42e531b:g0:n1",
        "source": "chinook-teaching:练习目录\\lab\\models\\query\\ChinookInvoiceQueryModel.qm"
      },
      "queryModel": "ChinookInvoiceQueryModel"
    },
    "executionTrace": {
      "jdbc": "NOT_EVALUATED",
      "l1Cache": "NOT_EVALUATED",
      "l2Cache": "NOT_EVALUATED",
      "route": "NOT_EVALUATED"
    },
    "limitations": [
      {
        "code": "RECOMPILED_NOT_EXECUTED_TRACE",
        "confidence": "EXACT",
        "message": "This evidence was produced by a fresh governed compilation. It is not the historical trace of an earlier execution."
      }
    ],
    "materializationTrace": {
      "decision": "SOURCE_QUERY_RETAINED",
      "definitions": [],
      "reasonCode": "PREAGG_NOT_CONFIGURED",
      "route": "RAW",
      "status": "EVALUATED"
    },
    "schemaVersion": "foggy-semantic-explain/v1",
    "securityTrace": {
      "affectedFields": [],
      "affectsFieldVisibility": false,
      "affectsJoin": false,
      "affectsPreAggregation": false,
      "conditions": [
        {
          "confidence": "EXACT",
          "field": "invoiceDate",
          "operator": "[)",
          "origin": "USER_SLICE",
          "path": "slice[0]",
          "redactedValue": "***",
          "valueType": "LIST<String>"
        }
      ],
      "effect": "ALLOW",
      "policyId": "PUBLIC",
      "policyVersion": "PUBLIC",
      "publicDecision": true,
      "status": "EVALUATED"
    },
    "sqlTrace": {
      "confidence": "OBSERVED",
      "exposed": true,
      "finalPhysicalSql": "select\tSUM(t1.Total) \"amount\",\tCOUNT(t1.InvoiceId) \"bills\",\t(SUM(t1.Total) / NULLIF(COUNT(t1.InvoiceId), 0)) \"averageAmount\"\tfrom Invoice t1\t where  1=1  and \tt1.InvoiceDate >=?  and \tt1.InvoiceDate <? ",
      "logicalSql": "select\tSUM(t1.Total) \"amount\",\tCOUNT(t1.InvoiceId) \"bills\",\t(SUM(t1.Total) / NULLIF(COUNT(t1.InvoiceId), 0)) \"averageAmount\"\tfrom Invoice t1\t where  1=1  and \tt1.InvoiceDate >=?  and \tt1.InvoiceDate <? ",
      "parameters": [
        {
          "confidence": "OBSERVED",
          "index": 1,
          "origin": "USER_SLICE",
          "redactedValue": "***",
          "valueType": "String"
        },
        {
          "confidence": "OBSERVED",
          "index": 2,
          "origin": "USER_SLICE",
          "redactedValue": "***",
          "valueType": "String"
        }
      ],
      "reasonCode": "SQL_CAPTURED_FROM_QUERY_EXECUTION_CONTEXT",
      "sourceOfTruth": "QueryExecutionContext.sql"
    }
  },
  "diagnostics": {
    "attributes": {},
    "warnings": []
  },
  "engine": "java",
  "runtimeApiVersion": "foggy-runtime-api/v1",
  "success": true
}
