Skip to content

Instantly share code, notes, and snippets.

@alculquicondor
Created August 21, 2015 20:25
Show Gist options
  • Select an option

  • Save alculquicondor/14dd3d189753aaec6387 to your computer and use it in GitHub Desktop.

Select an option

Save alculquicondor/14dd3d189753aaec6387 to your computer and use it in GitHub Desktop.
[
{
"SELECT": {
"distinctClause": null,
"intoClause": null,
"targetList": [
{
"RESTARGET": {
"name": null,
"indirection": null,
"val": {
"COLUMNREF": {
"fields": [
"region"
],
"location": 225
}
},
"location": 225
}
},
{
"RESTARGET": {
"name": null,
"indirection": null,
"val": {
"COLUMNREF": {
"fields": [
"product"
],
"location": 233
}
},
"location": 233
}
},
{
"RESTARGET": {
"name": "product_units",
"indirection": null,
"val": {
"FUNCCALL": {
"funcname": [
"sum"
],
"args": [
{
"COLUMNREF": {
"fields": [
"quantity"
],
"location": 246
}
}
],
"agg_order": null,
"agg_filter": null,
"agg_within_group": false,
"agg_star": false,
"agg_distinct": false,
"func_variadic": false,
"over": null,
"location": 242
}
},
"location": 242
}
},
{
"RESTARGET": {
"name": "product_sales",
"indirection": null,
"val": {
"FUNCCALL": {
"funcname": [
"sum"
],
"args": [
{
"COLUMNREF": {
"fields": [
"amount"
],
"location": 278
}
}
],
"agg_order": null,
"agg_filter": null,
"agg_within_group": false,
"agg_star": false,
"agg_distinct": false,
"func_variadic": false,
"over": null,
"location": 274
}
},
"location": 274
}
}
],
"fromClause": [
{
"RANGEVAR": {
"schemaname": null,
"relname": "orders",
"inhOpt": 2,
"relpersistence": "p",
"alias": null,
"location": 308
}
}
],
"whereClause": {
"SUBLINK": {
"subLinkType": 2,
"testexpr": {
"COLUMNREF": {
"fields": [
"region"
],
"location": 321
}
},
"operName": [
"="
],
"subselect": {
"SELECT": {
"distinctClause": null,
"intoClause": null,
"targetList": [
{
"RESTARGET": {
"name": null,
"indirection": null,
"val": {
"COLUMNREF": {
"fields": [
"region"
],
"location": 339
}
},
"location": 339
}
}
],
"fromClause": [
{
"RANGEVAR": {
"schemaname": null,
"relname": "top_regions",
"inhOpt": 2,
"relpersistence": "p",
"alias": null,
"location": 351
}
}
],
"whereClause": null,
"groupClause": null,
"havingClause": null,
"windowClause": null,
"valuesLists": null,
"sortClause": null,
"limitOffset": null,
"limitCount": null,
"lockingClause": null,
"withClause": null,
"op": 0,
"all": false,
"larg": null,
"rarg": null
}
},
"location": 328
}
},
"groupClause": [
{
"COLUMNREF": {
"fields": [
"region"
],
"location": 373
}
},
{
"COLUMNREF": {
"fields": [
"product"
],
"location": 381
}
}
],
"havingClause": null,
"windowClause": null,
"valuesLists": null,
"sortClause": null,
"limitOffset": null,
"limitCount": null,
"lockingClause": null,
"withClause": {
"WITHCLAUSE": {
"ctes": [
{
"COMMONTABLEEXPR": {
"ctename": "regional_sales",
"aliascolnames": null,
"ctequery": {
"SELECT": {
"distinctClause": null,
"intoClause": null,
"targetList": [
{
"RESTARGET": {
"name": null,
"indirection": null,
"val": {
"COLUMNREF": {
"fields": [
"region"
],
"location": 32
}
},
"location": 32
}
},
{
"RESTARGET": {
"name": "total_sales",
"indirection": null,
"val": {
"FUNCCALL": {
"funcname": [
"sum"
],
"args": [
{
"COLUMNREF": {
"fields": [
"amount"
],
"location": 44
}
}
],
"agg_order": null,
"agg_filter": null,
"agg_within_group": false,
"agg_star": false,
"agg_distinct": false,
"func_variadic": false,
"over": null,
"location": 40
}
},
"location": 40
}
}
],
"fromClause": [
{
"RANGEVAR": {
"schemaname": null,
"relname": "orders",
"inhOpt": 2,
"relpersistence": "p",
"alias": null,
"location": 72
}
}
],
"whereClause": null,
"groupClause": [
{
"COLUMNREF": {
"fields": [
"region"
],
"location": 88
}
}
],
"havingClause": null,
"windowClause": null,
"valuesLists": null,
"sortClause": null,
"limitOffset": null,
"limitCount": null,
"lockingClause": null,
"withClause": null,
"op": 0,
"all": false,
"larg": null,
"rarg": null
}
},
"location": 5,
"cterecursive": false,
"cterefcount": 0,
"ctecolnames": null,
"ctecoltypes": null,
"ctecoltypmods": null,
"ctecolcollations": null
}
},
{
"COMMONTABLEEXPR": {
"ctename": "top_regions",
"aliascolnames": null,
"ctequery": {
"SELECT": {
"distinctClause": null,
"intoClause": null,
"targetList": [
{
"RESTARGET": {
"name": null,
"indirection": null,
"val": {
"COLUMNREF": {
"fields": [
"region"
],
"location": 121
}
},
"location": 121
}
}
],
"fromClause": [
{
"RANGEVAR": {
"schemaname": null,
"relname": "regional_sales",
"inhOpt": 2,
"relpersistence": "p",
"alias": null,
"location": 133
}
}
],
"whereClause": {
"AEXPR": {
"name": [
">"
],
"lexpr": {
"COLUMNREF": {
"fields": [
"total_sales"
],
"location": 154
}
},
"rexpr": {
"SUBLINK": {
"subLinkType": 4,
"testexpr": null,
"operName": null,
"subselect": {
"SELECT": {
"distinctClause": null,
"intoClause": null,
"targetList": [
{
"RESTARGET": {
"name": null,
"indirection": null,
"val": {
"AEXPR": {
"name": [
"\/"
],
"lexpr": {
"FUNCCALL": {
"funcname": [
"sum"
],
"args": [
{
"COLUMNREF": {
"fields": [
"total_sales"
],
"location": 180
}
}
],
"agg_order": null,
"agg_filter": null,
"agg_within_group": false,
"agg_star": false,
"agg_distinct": false,
"func_variadic": false,
"over": null,
"location": 176
}
},
"rexpr": {
"A_CONST": {
"val": 10,
"location": 193
}
},
"location": 192
}
},
"location": 176
}
}
],
"fromClause": [
{
"RANGEVAR": {
"schemaname": null,
"relname": "regional_sales",
"inhOpt": 2,
"relpersistence": "p",
"alias": null,
"location": 201
}
}
],
"whereClause": null,
"groupClause": null,
"havingClause": null,
"windowClause": null,
"valuesLists": null,
"sortClause": null,
"limitOffset": null,
"limitCount": null,
"lockingClause": null,
"withClause": null,
"op": 0,
"all": false,
"larg": null,
"rarg": null
}
},
"location": 168
}
},
"location": 166
}
},
"groupClause": null,
"havingClause": null,
"windowClause": null,
"valuesLists": null,
"sortClause": null,
"limitOffset": null,
"limitCount": null,
"lockingClause": null,
"withClause": null,
"op": 0,
"all": false,
"larg": null,
"rarg": null
}
},
"location": 97,
"cterecursive": false,
"cterefcount": 0,
"ctecolnames": null,
"ctecoltypes": null,
"ctecoltypmods": null,
"ctecolcollations": null
}
}
],
"recursive": false,
"location": 0
}
},
"op": 0,
"all": false,
"larg": null,
"rarg": null
}
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment