MATIH Platform is in active MVP development. Documentation reflects current implementation status.
9. Query Engine & SQL
Overview

Query Engine API Reference

The Query Engine exposes REST APIs for query execution, analytics, caching, result export, scheduling, and cost estimation. All endpoints are served on port 8080 under the /v1 prefix and require tenant context via the X-Tenant-ID header.


Base URL

https://:hostname/v1

Endpoint Groups

GroupBase PathDescription
Query Endpoints/v1/queriesExecute, cancel, and manage queries
Analytics Endpoints/v1/analyticsPerformance analytics, trends, insights
Cache Endpoints/v1/cacheCache management, invalidation, warming
Export Endpoints/v1/queriesExport results to CSV, JSON, Parquet
Schedule Endpoints/v1/schedulesCreate and manage scheduled queries
Cost Endpoints/v1/queries/costQuery cost estimation and comparison

Common Headers

HeaderRequiredDescription
X-Tenant-IDYesUUID of the tenant
X-User-IDSome endpointsUUID of the executing user
AuthorizationYesBearer JWT token

Supported Query Engines

EngineDescription
TRINODefault engine for complex analytics and multi-join queries
CLICKHOUSEReal-time tables and simple aggregations
DUCKDBLocal analytical queries and embedded processing
STARROCKSHigh-throughput OLAP and materialized view serving
SPARK_ASYNCLarge-scale scans exceeding 100GB

Common Error Responses

StatusDescription
400Invalid SQL syntax or request parameters
401Missing or invalid authentication token
403Query blocked by row-level security or quota limit
404Query execution or resource not found
408Query execution timeout exceeded
429Query concurrency limit exceeded