This a very work in progress Native Data Connector for SQLServer made in the Hasura Hackathon August 2023. It is a fork of postgres-ndc and aims to follow the conventions established there.
Things we have:
- basic queries
- filtering
- basic ordering
- relationships
- variables
- sorting
Things we definitely don't have:
- database introspection
- explain queries
- reinstate benchmarks
The best view of progress is probably /crates/ndc-sqlserver/tests/
, and look
at which tests are still commented out. If you'd to contribute, a very good
start would be to uncomment one and try to fix any query errors.
- Install rustup.
- Install additional tools:
cargo install cargo-watch cargo-insta
rustup component add rust-analyzer
rustup component add clippy
rustup component add rustfmt
- Install just
- Install Docker
- Install protoc. Here are a few options:
brew install protobuf
apt-get install protobuf-compiler
dnf install protobuf-compiler
- Clone v3-engine in a directory near this one:
(cd .. && git clone git@github.com:hasura/v3-engine.git)
cargo build
Run the sqlserver agent with:
just run
- Start the sample chinook sqlserver db, compile, run tests, and rerun server on file changes:
just dev
- Query the connector via curl:
curl -H "Content-Type: application/json" \ --data "@crates/ndc-sqlserver/tests/goldenfiles/select_where_variable.json" \ http://localhost:8080/query \ | jq
Among the docker containers is a Jaeger instance for tracing/debugging, accessible at http://127.0.0.1:4002.
See debugging.md.
We can produce a flamegraph using just flamegraph
using flamegraph-rs. Follow the installation instructions.
See ./benchmarks/component/README.md.
A benchmark history can be viewed here.
See architecture.md.
-
Run
just dev
(orjust run
) -
Run
just run-engine
-
Connect to GraphiQL at http://localhost:3000 and run a query:
query { AlbumByID(AlbumId: 35) { Title } }
(or
just test-integrated
)
- Create a new file under
crates/ndc-sqlserver/tests/goldenfiles/<your-test-name>.json
- Create a new test in
crates/ndc-sqlserver/tests/tests.rs
that looks like this:#[tokio::test] async fn select_5() { let result = common::test_query("select_5").await; insta::assert_json_snapshot!(result); }
- Run the tests using
just dev
- Review the results using
cargo insta review
- Create a new folder under
crates/query-engine/tests/goldenfiles/<your-test-name>/
- Create
request.json
andtables.json
files in that folder to specify your request - Create a new test in
crates/query-engine/tests/tests.rs
that looks like this:#[tokio::test] async fn select_5() { let result = common::test_translation("select_5").await; insta::assert_snapshot!(result); }
- Run the tests using
just dev
- Review the results using
cargo insta review
We have a Prometheus / Grafana set up in Docker. Run just start-metrics
to
start them, you can then navigation to localhost:3001
for Grafana, or
localhost:9090
for Prometheus.
Run just lint
to run clippy linter
run just lint-apply
to attempt to autofix all linter suggestions
Check your formatting is great with just format-check
.
Format all Rust code with just format
.