English | 中文
SQLRec is an engine for building recommendation systems in SQL. Developers familiar with SQL can write recall, deduplication, ranking, and diversification logic, then publish the flow as an HTTP API. The engine handles data-source access, model training, and inference so users can focus on recommendation logic.
The current release is beta. Production use is not recommended, and interface compatibility is not guaranteed.
- Develop in SQL: Write recall, ranking, and other recommendation logic, then publish it as an API.
- Execute online flows: Run SQL with Calcite, with caching, parallel calls, timeouts, and fallbacks.
- Reuse your big data ecosystem: Use existing HMS tables and data on HDFS directly.
- Manage models through SQL: Train, deploy, and call models, or connect existing model services.
- Deploy on Kubernetes: Manage training and inference with Kubernetes and provided deployment scripts.
- Extend as needed: Add custom functions, data sources, and model backends.
- Troubleshoot easily: Inspect flows and diagnose issues with the UI, metrics, and traces.
See Architecture for component responsibilities and execution details.
The Docker demo includes sample data, a recommendation flow, and an API solely for trying the features. It requires no external services. To integrate SQLRec into your application, define your own tables connected to business data, SQL recommendation flows, and APIs, then configure model services and deployment as needed.
Start the demo with Docker:
docker run --rm -d --name sqlrec-demo \
-p 30000:30000 \
-p 30001:30001 \
sqlrec/sqlrec-demo:latestCall the built-in recommendation API:
curl -X POST http://localhost:30001/api/v1/demo_rec \
-H "Content-Type: application/json" \
-d '{"data":{"user_info":[{"user_id":1000001}]}}'The first call usually returns two items with fields such as item_id and rec_reason. Use user IDs 1000001 through 1000005. Repeated calls exclude previously recommended items; restart the container when the candidates are exhausted.
Open the SQLRec UI to inspect tables, functions, APIs, and execution DAGs.
docker exec -it sqlrec-demo /app/cli.shcache table quick_start_user as
select cast(1000001 as bigint) as user_id;
call demo_rec(quick_start_user);End each statement with a semicolon and press Ctrl+D to exit. The CLI and HTTP service keep separate in-memory data; CLI changes do not affect the API.
Stop the container when finished; --rm removes it automatically:
docker stop sqlrec-demo- Connect Data Sources: define tables connected to your business stores.
- Write a Recommendation Flow: define inputs and SQL functions to compose your business logic.
- Publish and Call an API: publish your recommendation function for application calls.
- Model Training and Online Inference: connect an existing model service or train a model as needed.
- Service Deployment: prepare the runtime environment. See the Docker Quick Start for an example of loading custom SQL locally.
See the SQLRec User Manual for more.