A Java library that converts SQL queries into MongoDB query documents and aggregation pipelines.
sql-to-mongo-db-query-converter is a Java library that parses SQL queries and converts them into equivalent MongoDB query documents and aggregation pipelines. It solves the problem of allowing developers with SQL expertise to query MongoDB databases without learning MongoDB's native query syntax, facilitating migration or hybrid database workflows.
Java developers working with MongoDB who need to write complex queries using SQL syntax, or teams migrating from SQL databases to MongoDB seeking a familiar query interface.
It provides a comprehensive, feature-rich translation layer that supports a wide range of SQL constructs—including joins, aggregations, and custom functions—while offering both a programmatic API and a standalone CLI for flexibility.
sql-to-mongo-db-query-converter
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports SELECT, UPDATE, DELETE, JOINs via $lookup, GROUP BY, and HAVING clauses, translating them to MongoDB find(), update(), delete(), and aggregate() operations, as shown in numerous README examples.
Includes functions like date() for natural language dates and regexMatch() for pattern matching, easing the transition from SQL-specific functions to MongoDB operators.
Offers a standalone command-line interface with interactive mode for real-time query conversion and direct execution against MongoDB, useful for testing and prototyping.
Provides field type mapping for ObjectId, dates, booleans, and numbers, ensuring accurate query construction and reducing type-related errors.
Relies on jsqlparser, which may have bugs or lag behind SQL standard updates, as indicated by past bug fixes in the change log affecting translation accuracy.
The conversion process adds latency, making it less suitable for high-throughput applications compared to native MongoDB queries, especially in real-time scenarios.
Does not support all SQL or MongoDB features, such as window functions or advanced aggregation stages like $graphLookup, requiring workarounds or native queries for gaps.