Skip to content

misterrodger/semantic-query-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

semantic-query-builder

go run cmd/server/main/go

Basic endpoints

curl http://localhost:8080/health

curl http://localhost:8080/api/v1/metrics | python3 -m json.tool

curl http://localhost:8080/api/v1/metrics/mrr

curl http://localhost:8080/api/v1/catalog

curl http://localhost:8080/api/v1/datasources | python3 -m json.tool

Create a new metric

curl -X POST http://localhost:8080/api/v1/metrics
-H "Content-Type: application/json"
-d '{ "name": "total_customers", "display_name": "Total Customers", "description": "Total number of customers", "sql_expression": "SELECT COUNT(*) as value FROM customers", "return_type": "count", "depends_on": ["customers.id"], "tags": ["customers"] }'

Resolve a simple metric query, no user filters provided

curl -X POST http://localhost:8080/api/v1/metrics/mrr/resolve \

Resolve a metric with filters

curl -X POST http://localhost:8080/api/v1/metrics/total_revenue/resolve
-H "Content-Type: application/json"
-d '{ "filters": [ {"column": "status", "operator": "=", "value": "completed"}, {"column": "created_at", "operator": ">", "value": "2024-01-01"} ] }'

Get metric metadata including dependencies

curl http://localhost:8080/api/v1/metrics/mrr/info

Validate an incorrect metric before creating

curl -X POST http://localhost:8080/api/v1/metrics/validate
-H "Content-Type: application/json"
-d '{ "name": "test_metric", "display_name": "Test Metric", "sql_expression": "SELECT COUNT(*) FROM nonexistent_table", "return_type": "count", "depends_on": ["nonexistent_table.id"] }'

Validate a correct metric

curl -X POST http://localhost:8080/api/v1/metrics/validate
-H "Content-Type: application/json"
-d '{ "name": "customer_count", "display_name": "Total Customer Count", "sql_expression": "SELECT COUNT(*) as value FROM customers", "return_type": "count", "depends_on": ["customers.id"] }'

Test IN operator filter

curl -X POST http://localhost:8080/api/v1/metrics/total_revenue/resolve
-H "Content-Type: application/json"
-d '{ "filters": [ {"column": "status", "operator": "IN", "value": ["completed", "pending"]} ] }'

Run tests

go test ./... -v

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors