{
  "head":{
    "type":"APACHE_DRILL_LOGICAL",
    "version":"1",
    "generator":{
      "type":"manual",
      "info":"na"
    }
  },
  "storage":{
    "console": {"type": "console", "enabled":  true},
    "fs1": {"type": "fs", "root":"file:///", "enabled":  true},
    "cp": {"type": "classpath", "enabled":  true}
  },
  "query":[

                {
                  "@id":"1",
                  "op": "scan",
                  "memo": "initial_scan",
                  "ref": "donuts",
                  "storageengine": "cp",
                  "selection": {
                    "path": "/donuts.json",
                    "type": "JSON"
                  }
                },
        {
                  "@id":"2",
                  "input":"1",
                  "op": "transform",
                  "transforms": [
                    { "ref": "quantity", "expr": "donuts.sales"}
                  ]
                },
                {
                  "@id":"3",
                  "input":"2",
                  "op": "filter",
                  "expr": "donuts.ppu < 1.00"
                },
                {
                  "@id":"4",
                  "input":"3",
                  "op": "segment",
                  "ref": "ppusegment",
                  "exprs": ["donuts.ppu"]
                },
                {
                  "@id":"5",
                  "input":"4",
                  "op": "collapsingaggregate",
                  "within": "ppusegment",
                  "carryovers": ["donuts.ppu"],
                  "aggregations": [
                    { "ref": "donuts.typeCount",  "expr": "count(1)" },
                    { "ref": "donuts.quantity",  "expr": "sum(quantity)" },
                    { "ref": "donuts.sales",  "expr": "sum(donuts.ppu * quantity)" }
                  ]
                },
                {
                  "@id":"6",
                  "input":"5",
                  "op": "order",
                  "orderings": [
                    {"order": "DESC", "expr": "donuts.ppu" }
                  ]
                },
                {
                  "@id":"7",
                  "input":"6",
                  "op": "project",
                  "projections": [
                    { "ref": "output.output", "expr": "donuts" }
                  ]
                },
               {
          "@id":"8",
                  "input":"7",
                  "op": "limit",
          "first": 0,
          "last": 100
        },
                {
                  "@id":"9",
                  "input":"8",
                  "op": "store",
                  "memo": "output sink",
                  "storageengine": "console",
                  "target": {"pipe": "STD_OUT"}
                }
  ]
}

