{"id":25157528,"url":"https://github.com/mongodb/mongosql","last_synced_at":"2025-11-11T21:02:33.101Z","repository":{"id":275860253,"uuid":"923104017","full_name":"mongodb/mongosql","owner":"mongodb","description":"The mongosql compiler","archived":false,"fork":false,"pushed_at":"2025-04-23T02:52:36.000Z","size":29922,"stargazers_count":4,"open_issues_count":1,"forks_count":7,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-23T03:30:36.020Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mongodb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-27T16:46:16.000Z","updated_at":"2025-04-23T02:52:39.000Z","dependencies_parsed_at":"2025-02-20T19:26:29.877Z","dependency_job_id":"2d3af44e-96ca-4154-971c-379b026454d2","html_url":"https://github.com/mongodb/mongosql","commit_stats":null,"previous_names":["mongodb/mongosql"],"tags_count":137,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongosql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongosql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongosql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongosql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mongodb","download_url":"https://codeload.github.com/mongodb/mongosql/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251678762,"owners_count":21626397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-09T01:23:40.907Z","updated_at":"2025-11-11T21:02:33.095Z","avatar_url":"https://github.com/mongodb.png","language":"Rust","readme":"# MongoDB MongoSQL Compiler\n\nThis document contains instructions for building and testing the MongoSQL compiler\n\n## Build Requirements\n\n### Minimum Rust version\n1.52.0\n\n### Minimum go version\n1.15\n\n## Building\n\n`cargo build` from the main directory\n\nFor release mode, use `cargo build --release`, this will remove debugging support and will optimize\nthe code.\n\n## Rust testing\n\nThere are several types of tests for the Rust code: unit tests, fuzz tests, index usage tests, e2e\ntests, and spec tests. Each of these test types can be run in isolation. Fuzz tests should always\nexist in (sub)modules named `fuzz_test`, so this common name is used as a filter for running the\ntests. All integration tests require a running mongod with data loaded into it. Integration tests\ninclude: e2e, error, index_usage, spec/query, and schema_derivation tests. The tests are specified\nin the `tests` directory, and their data is specified in the `testdata` directory. To load the data,\nuse the [sql-engines-common-test-infra](https://github.com/mongodb/sql-engines-common-test-infra)\n`data-loader` tool. See `cargo run --bin data-loader -- --help` in that repo for more details.\n\nThe [Rust handbook](https://doc.rust-lang.org/cargo/commands/cargo-test.html) has full guidelines\non how to use `cargo test`. Below are suggested ways of running the different sets of tests.\n\n### Unit testing\n\nAll unit tests in the repository.\n\n`cargo test -- --skip fuzz_test` from the main directory\n\n### Fuzz testing\n\nFuzz tests for pretty-printing.\n\n`cargo test fuzz_test` from the main directory\n\n### Index Usage testing\n\nIndex-usage assertion tests. These tests specify queries and expected index utilization.\nRequires a running mongod.\n\n`cargo test --features=index --package=e2e-tests` from the main directory\n\n### e2e testing\n\nEnd-to-end query tests that do not exist in the spec. These tests specify queries and expected\nresult sets and execute against an actual database. Requires a running mongod.\n\n`cargo test --features=e2e --package=e2e-tests` from the main directory\n\n### errors testing\n\nerror tests are e2e tests for our errors. These tests specify a SQL query and have an expected\nerror that they should cause. Requires a running mongod.\n\n`cargo test --features=error --package=e2e-tests` from the main directory\n\n### Spec query testing\n\nThe query spec tests that specify language behavior. Requires a running mongod.\n\n`cargo test --features=query --package=e2e-tests` from the main directory\n\n### Schema derivation testing\n\nThe schema derivation tests assert result set schema using schema derivation. Requires a running mongod.\n\n`cargo test --features=schema_derivation --package=e2e-tests` from the main directory\n\n### Evergreen testing\n\nOur suite of integration tests is automatically created by the `build.rs` script in\n`evergreen/create-tasks/build.rs`. If you modify this file to add a new version of\nMongoDB or to test against different topologies and do not have your editor/IDE\nconfigured to automatically run a check command that builds on save, ensure you\nrun `cargo build --package create-tasks`.\n\nEnsure you commit the changes to `evergreen/suite-tasks.yml`.\n\n### Spec testing\n\nThe syntactic rewriter and type-constraint spec tests.\n\n`cargo test -- --ignored` from the main directory\n\n### All testing\n\n`cargo test -- --include-ignored` from the main directory\n\n## Go testing\n\nThere are two types of tests for the Go code: integration tests and spec tests.\nThe spec tests have been separated out since they are not part of the MongoSQL Go\nAPI.\n\n### Building for go testing\n\nIn order to run the integration tests, the Rust code must be built with a\nspecial feature.\n\n`cargo build --features \"mongosql-c/test\"` from the main directory. This compiles\nin code necessary for the Go tests to pass.\n\n### Environment Variables\nIf testing on a Mac using ARM architecture, such as the M1 chip, the following Go environment variables may be required.\n```\nexport GOOS=darwin\nexport GOARCH=arm64\nexport CGO_ENABLED=1\n```\n\n### Integration testing\n\n```\n$ cd go/mongosql\n$ export GOPRIVATE=github.com/10gen/*\n$ export LIBRARY_PATH=$(cd ../.. \u0026\u0026 pwd)/target/debug\n$ export LD_LIBRARY_PATH=$(cd ../.. \u0026\u0026 pwd)/target/debug\n$ go test\n```\n\nReplace `debug` with `release` in paths above to test release builds\n\n### Spec testing\n\n`go test -tags spectests`\n\nYou will need a running `mongod` on the default port (27017) in order\nto run result tests.\n\n#### Specifying tests\n\nTo target specific tests, specify the appropriate file and test name:\n\n`go test -v -tags spectests -run TestSpecResultSets/filename.yml/Test_name_snake_case`\n\nFor example, the following test is in `mongosql-rs/tests/spec_tests/query_tests/identifier.yml`:\n\n```yml\n  - description: Unaliased use of field reference expression with $ and .\n    query: \"SELECT * FROM bar WHERE `$a.b` = 4\"\n    current_db: foo\n    result:\n      - {'bar': {'_id': 4, '$a.b': 4}}\n```\n\n* To run this test only: `go test -v -tags spectests -run TestSpecResultSets/identifier.yml/Unaliased_use_of_field_reference_expression_with_$_and_.`\n* To run this file only: `go test -v -tags spectests -run TestSpecResultSets/identifier.yml`\n\n## Debugging visitgen\n\nSince our visitors are created by a proc_macro that utilizes many macros, it is difficult to figure out\nwhat the generated walk and visit rust files look like just by reading the code. To see what the generated\nrust files look like, run:\n\n`cargo build --features debug-visitor-output`\n\nThis command will generate the visit and walk rust files and put them in subdirectories of the `target`\ndirectory called `\u003csome_enum_or_struct\u003e_visit` and `\u003csome_enum_or_struct\u003e_walk` respectively. The\n`\u003csome_enum_or_struct\u003e` value will be one of the structs or enums that is input to `visitgen::generate_visitors! {...}`\nand will be the same for corresponding visit and walk files.\n\n## Dependencies\n\nAll are managed by Go modules for Go, and Cargo for Rust\n\n## License\n\nThis project is licensed under the [Apache License 2.0](/LICENSE).\nThis product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (\u003chttp://www.openssl.org/\u003e).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongodb%2Fmongosql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmongodb%2Fmongosql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongodb%2Fmongosql/lists"}