Skip to content

DSL Query API ​

This document introduces the HTTP query interface of Foggy Dataset Model. For complete DSL syntax, please refer to JSON Query DSL.

This page documents the compatible /jdbc-model/query-model/v2 surface for an embedded Dataset Model application. Java Runtime management, model lifecycle, and governed queries use /api/v1/...; these are different HTTP contracts.

1. Overview ​

1.1 Basic Information ​

  • Base URL: /jdbc-model/query-model
  • Content-Type: application/json
  • Response Format: JSON

1.2 Interface List ​

MethodPathDescription
POST/v2/{model}Query model data (recommended)
POST/queryKpiKPI summary query

2. Query Model Data ​

2.1 Interface Address ​

POST /jdbc-model/query-model/v2/{model}

2.2 Path Parameters ​

ParameterTypeRequiredDescription
modelstringYesQuery model name, e.g., FactOrderQueryModel

2.3 Request Body Structure ​

json
{
    "page": 1,
    "pageSize": 20,
    "param": {
        "columns": ["orderId", "customer$caption", "totalAmount"],
        "slice": [
            { "field": "orderStatus", "op": "=", "value": "COMPLETED" }
        ],
        "groupBy": [
            { "field": "customer$customerType" }
        ],
        "orderBy": [
            { "field": "totalAmount", "order": "desc" }
        ],
        "calculatedFields": [...],
        "returnTotal": true
    }
}

2.4 Pagination Parameters ​

ParameterTypeRequiredDefaultDescription
pageintegerNo1Page number, starting from 1
pageSizeintegerNo10Number of items per page
startintegerNo0Starting record number (choose one with page)
limitintegerNo10Number of items to return (choose one with pageSize)

2.5 param Parameters ​

ParameterTypeRequiredDescription
columnsstring[]NoQuery columns, empty returns all columns with permissions. See Field Reference Format
exColumnsstring[]NoExclude columns
sliceSliceRequestDef[]NoFilter conditions. See Filter Conditions
groupByGroupRequestDef[]NoGroup by fields. See Grouping
orderByOrderRequestDef[]NoOrder by fields. See Sorting
calculatedFieldsCalculatedFieldDef[]NoDynamic calculated fields. See Calculated Fields
returnTotalbooleanNoWhether to return total count and summary data

3. KPI Summary Query ​

Quickly get measure summary values without pagination.

3.1 Interface Address ​

POST /jdbc-model/query-model/queryKpi

3.2 Request Body Structure ​

json
{
    "queryModel": "FactSalesQueryModel",
    "columns": ["salesQuantity", "salesAmount", "profitAmount"],
    "slice": [
        { "field": "salesDate$caption", "op": "[)", "value": ["2024-01-01", "2024-07-01"] },
        { "field": "product$category", "op": "=", "value": "数码电器" }
    ]
}

3.3 Request Parameters ​

ParameterTypeRequiredDescription
queryModelstringYesQuery model name
columnsstring[]YesMeasure fields to summarize
sliceSliceRequestDef[]NoFilter conditions

3.4 Response Example ​

json
{
    "code": 0,
    "data": {
        "salesQuantity": 15000,
        "salesAmount": 8990000.00,
        "profitAmount": 1798000.00
    }
}

4. Response Structure ​

4.1 Response Body ​

json
{
    "code": 0,
    "data": {
        "items": [
            {
                "orderId": "ORD202401010001",
                "orderStatus": "COMPLETED",
                "customer$caption": "Customer A",
                "totalAmount": 1299.00
            }
        ],
        "total": 100,
        "totalData": {
            "total": 100,
            "totalAmount": 129900.00
        }
    },
    "msg": "success"
}

4.2 Response Fields ​

FieldTypeDescription
codeintegerStatus code, 0 indicates success
data.itemsarrayDetail data list (paginated data)
data.totalintegerTotal number of records matching conditions
data.totalDataobjectSummary data (returned only when returnTotal=true)
msgstringMessage

4.3 totalData Description ​

  • Contains aggregated values of measure fields specified in columns
  • Aggregates all data matching conditions, not affected by pagination
  • Returned only when returnTotal=true is set

5. Error Handling ​

5.1 Error Codes ​

Error CodeDescription
0Success
400Request parameter error
403No permission to access
404Query model not found
500Server internal error

5.2 Error Response Example ​

json
{
    "code": 404,
    "msg": "Query model 'InvalidModel' not found",
    "data": null
}

6. Quick Examples ​

6.1 Detail Query ​

json
POST /jdbc-model/query-model/v2/FactOrderQueryModel

{
    "page": 1,
    "pageSize": 20,
    "param": {
        "columns": ["orderId", "orderStatus", "customer$caption", "totalAmount"],
        "slice": [
            { "field": "orderStatus", "op": "in", "value": ["COMPLETED", "SHIPPED"] }
        ],
        "orderBy": [
            { "field": "totalAmount", "order": "desc" }
        ],
        "returnTotal": true
    }
}

6.2 Group Summary ​

json
POST /jdbc-model/query-model/v2/FactOrderQueryModel

{
    "page": 1,
    "pageSize": 100,
    "param": {
        "columns": ["customer$customerType", "totalQuantity", "totalAmount"],
        "groupBy": [
            { "field": "customer$customerType" }
        ],
        "orderBy": [
            { "field": "totalAmount", "order": "desc" }
        ]
    }
}

For more examples, please refer to JSON Query DSL - Complete Examples.


Next Steps ​