{
  "data": {
    "basis": "RECOMPILED",
    "compilationTrace": {
      "events": [
        {
          "confidence": "EXACT",
          "decision": "NORMALIZED",
          "details": {
            "requestedFieldCount": 2
          },
          "event": "SEMANTIC_DSL_NORMALIZED",
          "observedAt": "2026-10-25T06:17:27.233420200Z",
          "reasonCode": "DSL_NORMALIZED",
          "sequence": 1,
          "stage": "NORMALIZATION",
          "status": "EVALUATED"
        },
        {
          "confidence": "EXACT",
          "decision": "RAW",
          "details": {},
          "event": "PRE_AGGREGATION_ROUTING",
          "observedAt": "2026-10-25T06:17:27.235420300Z",
          "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-25T06:17:27.236924200Z",
          "reasonCode": "PREAGG_NOT_CONFIGURED",
          "sequence": 3,
          "stage": "SQL",
          "status": "EVALUATED"
        }
      ],
      "fieldResolution": [
        {
          "confidence": "EXACT",
          "requested": "customerCode",
          "resolved": "customerCode",
          "tableField": "customerCode",
          "tableModel": "LegacyBillModel"
        },
        {
          "confidence": "OBSERVED",
          "requested": "amount",
          "resolved": "amount"
        }
      ],
      "normalizedConditions": [
        {
          "confidence": "EXACT",
          "field": "invoiceDate",
          "operator": "[)",
          "origin": "USER_SLICE",
          "path": "slice[0]",
          "redactedValue": "***",
          "valueType": "LIST<String>"
        }
      ],
      "normalizedDsl": {
        "autoFixDimCaption": false,
        "autoGroupBy": true,
        "calculatedFields": [
          {
            "agg": "SUM",
            "expression": "sum(invoiceAmount)",
            "name": "amount"
          }
        ],
        "columns": [
          "customerCode",
          "amount"
        ],
        "distinct": false,
        "groupBy": [
          {
            "agg": "null",
            "field": "customerCode"
          },
          {
            "agg": "SUM",
            "field": "amount"
          }
        ],
        "optimizeAggSqlEnabled": true,
        "orderBy": [
          {
            "dir": "desc",
            "field": "amount",
            "nullFirst": false,
            "nullLast": false
          },
          {
            "dir": "asc",
            "field": "customerCode",
            "nullFirst": false,
            "nullLast": false
          }
        ],
        "postAggregateCalculations": [],
        "queryModel": "LegacyBillQueryModel",
        "returnTotal": false,
        "slice": [
          {
            "$and": [],
            "$or": [],
            "field": "invoiceDate",
            "maxDepth": 0,
            "op": "[)",
            "value": "***"
          }
        ],
        "strictColumns": true,
        "withSubtotals": false
      },
      "originalDsl": {
        "captionMatchMode": "EXACT",
        "columns": [
          "customerCode",
          "sum(invoiceAmount) as amount"
        ],
        "distinct": false,
        "groupBy": [
          {
            "field": "customerCode"
          }
        ],
        "limit": 3,
        "mismatchHandleStrategy": "ABORT",
        "orderBy": [
          {
            "dir": "desc",
            "field": "amount",
            "nullFirst": false,
            "nullLast": false
          },
          {
            "dir": "asc",
            "field": "customerCode",
            "nullFirst": false,
            "nullLast": false
          }
        ],
        "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",
              "customerCode",
              "amount"
            ],
            "parameterCount": 2,
            "requiresSqlBoundary": false,
            "sqlAlias": "base",
            "type": "ROW_STAGE"
          },
          {
            "filterAliases": [],
            "id": "agg",
            "inputAliases": [
              "invoiceDate",
              "customerCode",
              "amount"
            ],
            "orderAliases": [],
            "outputAliases": [
              "customerCode",
              "amount"
            ],
            "parameterCount": 0,
            "requiresSqlBoundary": false,
            "sqlAlias": "base",
            "type": "AGGREGATE_STAGE"
          },
          {
            "filterAliases": [],
            "id": "final",
            "inputAliases": [
              "customerCode",
              "amount"
            ],
            "orderAliases": [
              "amount",
              "customerCode"
            ],
            "outputAliases": [
              "customerCode",
              "amount"
            ],
            "parameterCount": 0,
            "requiresSqlBoundary": false,
            "sqlAlias": "final",
            "type": "FINAL_STAGE"
          }
        ],
        "unsupported": [],
        "version": "v1"
      }
    },
    "definitionTrace": {
      "fields": [
        {
          "dataType": "STRING",
          "fieldType": "property",
          "lineage": [
            {
              "confidence": "EXACT",
              "from": "LegacyBillQueryModel.invoiceId",
              "reasonCode": "QM_TO_TM_MODEL_STRUCTURE",
              "to": "LegacyBillModel.invoiceId"
            },
            {
              "column": "invoice_id",
              "confidence": "EXACT",
              "from": "LegacyBillModel.invoiceId",
              "reasonCode": "VIEW_OUTPUT_COLUMN_MODEL_STRUCTURE",
              "to": "viewSql.output.invoice_id"
            },
            {
              "confidence": "OPAQUE",
              "from": "viewSql.output.invoice_id",
              "reasonCode": "VIEW_SQL_SOURCE_OPAQUE",
              "to": "<opaque-view-source>"
            }
          ],
          "queryField": "LegacyBillQueryModel.invoiceId",
          "references": [],
          "tableField": "invoiceId",
          "tableModel": "LegacyBillModel"
        },
        {
          "dataType": "STRING",
          "fieldType": "property",
          "lineage": [
            {
              "confidence": "EXACT",
              "from": "LegacyBillQueryModel.customerCode",
              "reasonCode": "QM_TO_TM_MODEL_STRUCTURE",
              "to": "LegacyBillModel.customerCode"
            },
            {
              "column": "customer_code",
              "confidence": "EXACT",
              "from": "LegacyBillModel.customerCode",
              "reasonCode": "VIEW_OUTPUT_COLUMN_MODEL_STRUCTURE",
              "to": "viewSql.output.customer_code"
            },
            {
              "confidence": "OPAQUE",
              "from": "viewSql.output.customer_code",
              "reasonCode": "VIEW_SQL_SOURCE_OPAQUE",
              "to": "<opaque-view-source>"
            }
          ],
          "queryField": "LegacyBillQueryModel.customerCode",
          "references": [],
          "tableField": "customerCode",
          "tableModel": "LegacyBillModel"
        },
        {
          "dataType": "DATETIME",
          "fieldType": "property",
          "lineage": [
            {
              "confidence": "EXACT",
              "from": "LegacyBillQueryModel.invoiceDate",
              "reasonCode": "QM_TO_TM_MODEL_STRUCTURE",
              "to": "LegacyBillModel.invoiceDate"
            },
            {
              "column": "invoice_date",
              "confidence": "EXACT",
              "from": "LegacyBillModel.invoiceDate",
              "reasonCode": "VIEW_OUTPUT_COLUMN_MODEL_STRUCTURE",
              "to": "viewSql.output.invoice_date"
            },
            {
              "confidence": "OPAQUE",
              "from": "viewSql.output.invoice_date",
              "reasonCode": "VIEW_SQL_SOURCE_OPAQUE",
              "to": "<opaque-view-source>"
            }
          ],
          "queryField": "LegacyBillQueryModel.invoiceDate",
          "references": [],
          "tableField": "invoiceDate",
          "tableModel": "LegacyBillModel"
        },
        {
          "dataType": "STRING",
          "fieldType": "property",
          "lineage": [
            {
              "confidence": "EXACT",
              "from": "LegacyBillQueryModel.billingCountry",
              "reasonCode": "QM_TO_TM_MODEL_STRUCTURE",
              "to": "LegacyBillModel.billingCountry"
            },
            {
              "column": "billing_country",
              "confidence": "EXACT",
              "from": "LegacyBillModel.billingCountry",
              "reasonCode": "VIEW_OUTPUT_COLUMN_MODEL_STRUCTURE",
              "to": "viewSql.output.billing_country"
            },
            {
              "confidence": "OPAQUE",
              "from": "viewSql.output.billing_country",
              "reasonCode": "VIEW_SQL_SOURCE_OPAQUE",
              "to": "<opaque-view-source>"
            }
          ],
          "queryField": "LegacyBillQueryModel.billingCountry",
          "references": [],
          "tableField": "billingCountry",
          "tableModel": "LegacyBillModel"
        },
        {
          "aggregationFormula": "SUM(invoice_amount)",
          "dataType": "MONEY",
          "fieldType": "measure",
          "lineage": [
            {
              "confidence": "EXACT",
              "from": "LegacyBillQueryModel.invoiceAmount",
              "reasonCode": "QM_TO_TM_MODEL_STRUCTURE",
              "to": "LegacyBillModel.invoiceAmount"
            },
            {
              "confidence": "EXACT",
              "expression": "SUM(invoice_amount)",
              "from": "LegacyBillModel.invoiceAmount",
              "reasonCode": "AGGREGATION_MODEL_STRUCTURE",
              "to": "SUM(invoice_amount)"
            },
            {
              "column": "invoice_amount",
              "confidence": "EXACT",
              "from": "LegacyBillModel.invoiceAmount",
              "reasonCode": "VIEW_OUTPUT_COLUMN_MODEL_STRUCTURE",
              "to": "viewSql.output.invoice_amount"
            },
            {
              "confidence": "OPAQUE",
              "from": "viewSql.output.invoice_amount",
              "reasonCode": "VIEW_SQL_SOURCE_OPAQUE",
              "to": "<opaque-view-source>"
            }
          ],
          "queryField": "LegacyBillQueryModel.invoiceAmount",
          "references": [],
          "tableField": "invoiceAmount",
          "tableModel": "LegacyBillModel"
        }
      ],
      "joins": [],
      "model": {
        "dependencies": [
          {
            "kind": "TABLE",
            "name": "LegacyBillModel"
          }
        ],
        "kind": "QUERY",
        "name": "LegacyBillQueryModel",
        "namespace": "file-legacy",
        "revision": "source:563e3217-d1f8-42f9-9444-e3b5cb3d8955:g0:n21",
        "source": "file-legacy-teaching:练习目录\\lab\\files\\series\\chapter-32\\models\\query\\LegacyBillQueryModel.qm"
      },
      "queryModel": "LegacyBillQueryModel"
    },
    "executionTrace": {
      "jdbc": "NOT_EVALUATED",
      "l1Cache": "NOT_EVALUATED",
      "l2Cache": "NOT_EVALUATED",
      "route": "NOT_EVALUATED"
    },
    "limitations": [
      {
        "code": "VIEW_SQL_SOURCE_OPAQUE",
        "confidence": "OPAQUE",
        "message": "An arbitrary viewSql has no declared sourceRefs; its underlying physical lineage was not inferred from SQL text."
      },
      {
        "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\tt1.customer_code \"customerCode\",\tSUM(t1.invoice_amount) \"amount\"\tfrom (SELECT b.id0 AS invoice_id,m.customer_code,b.d0 AS invoice_date,b.n0 AS billing_country,b.v0 / 100.0 AS invoice_amount FROM legacy_bill b JOIN legacy_customer_map m ON b.c0=m.old_code WHERE b.s0='V') t1\t where  1=1  and \tt1.invoice_date >=?  and \tt1.invoice_date <? \tgroup by t1.customer_code order by SUM(t1.invoice_amount) desc,\tt1.customer_code asc",
      "logicalSql": "select\tt1.customer_code \"customerCode\",\tSUM(t1.invoice_amount) \"amount\"\tfrom (SELECT b.id0 AS invoice_id,m.customer_code,b.d0 AS invoice_date,b.n0 AS billing_country,b.v0 / 100.0 AS invoice_amount FROM legacy_bill b JOIN legacy_customer_map m ON b.c0=m.old_code WHERE b.s0='V') t1\t where  1=1  and \tt1.invoice_date >=?  and \tt1.invoice_date <? \tgroup by t1.customer_code order by SUM(t1.invoice_amount) desc,\tt1.customer_code asc",
      "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
}
