Skip to content

MongoDB Render updates#11840

Merged
ea-rus merged 43 commits into
mindsdb:releases/25.13.0from
tino097:feature/mongodb-renderer-improvement
Dec 11, 2025
Merged

MongoDB Render updates#11840
ea-rus merged 43 commits into
mindsdb:releases/25.13.0from
tino097:feature/mongodb-renderer-improvement

Conversation

@tino097
Copy link
Copy Markdown
Contributor

@tino097 tino097 commented Oct 31, 2025

Description

Update mongodb_render to handle subqueries in the SELECT statements.
Adding more tests to cover different scenarios

Fixes #11837

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ⚡ New feature (non-breaking change which adds functionality)
  • 📢 Breaking change (fix or feature that would cause existing functionality not to work as expected)
  • 📄 This change requires a documentation update

Verification Process

To ensure the changes are working as expected:

  • Test Location: tests/unit/handlers/test_mongodb.py
  • Verification Steps: Outline the steps or queries needed to validate the change. Include any data, configurations, or actions required to reproduce or see the new functionality.

Additional Media:

  • I have attached a brief loom video or screenshots showcasing the new functionality or change.
image

Checklist:

  • My code follows the style guidelines(PEP 8) of MindsDB.
  • I have appropriately commented on my code, especially in complex areas.
  • Necessary documentation updates are either made or tracked in issues.
  • Relevant unit and integration tests are updated or added.

@tino097 tino097 changed the title [WIP]MondgoDB Render updates MondgoDB Render updates Nov 2, 2025
@tino097 tino097 marked this pull request as ready for review November 2, 2025 19:24
@tino097 tino097 changed the title MondgoDB Render updates MongoDB Render updates Nov 2, 2025
@ZoranPandovski ZoranPandovski requested a review from ea-rus November 2, 2025 22:08
@maher00746
Copy link
Copy Markdown

hello @tino097
Do your recent changes support building complex queries on MongoDB documents — especially when some fields contain JSON or nested documents?
like in this example, i'm asking questions require complex queries
image

@tino097
Copy link
Copy Markdown
Contributor Author

tino097 commented Nov 10, 2025

@maher00746 thanks for the example, i will take a look
Current changes are to allow subqueries but there is a room for improvements

@maher00746
Copy link
Copy Markdown

Hi @tino097, thanks for your reply,

The issue is that MindsDB treats MongoDB documents as JSON (or plain text), especially when they contain nested structures. Even when there are integer values, MindsDB still interprets them as text, which causes problems when applying SQL queries, since SQL logic doesn’t work properly on nested JSON data.

Yesterday, I tried a workaround by “unifying” the data: using an LLM to extract nested documents and store them in a structured table format. This effectively converted the MongoDB data into a relational structure. However, this approach isn’t ideal, because we end up querying the modified local data instead of the original MongoDB source, which means we need continuous synchronization.

Additionally, the extraction and unification process is expensive, as it relies on an LLM and consumes significant time and tokens.

I’ve been exploring ways to treat MongoDB data as structured data so that SQL queries could run directly on it, but so far, no luck.

@tino097
Copy link
Copy Markdown
Contributor Author

tino097 commented Nov 10, 2025

@maher00746 MindsDB is treating documents as tables and the SQL queries are later translated to MongoDB via its handler. In your case some of the complex functionalities are not correctly handled which will needs to be implemented next

edit:
If you are able to use this branch so you can test it to check if it will work
image

Comment thread mindsdb/integrations/handlers/mongodb_handler/utils/mongodb_render.py Outdated
Comment thread mindsdb/integrations/handlers/mongodb_handler/utils/mongodb_render.py Outdated
Comment thread tests/unit/handlers/test_mongodb.py
Comment thread mindsdb/integrations/handlers/mongodb_handler/utils/mongodb_render.py Outdated
@tino097 tino097 requested a review from ea-rus November 17, 2025 14:42
ea-rus
ea-rus previously approved these changes Nov 19, 2025
@tino097 tino097 requested a review from a team as a code owner December 1, 2025 17:34
@tino097 tino097 changed the base branch from develop to main December 1, 2025 17:35
@Cenrax
Copy link
Copy Markdown

Cenrax commented Dec 2, 2025

@ea-rus hey when this pull request will get merged

Comment thread docs/setup/environment-vars.mdx
@ea-rus ea-rus changed the base branch from main to releases/25.13.0 December 9, 2025 14:41
@martyna-mindsdb
Copy link
Copy Markdown
Contributor

@ea-rus @tino097
Please feel free to merge it to 25.13.0, as it has been reviewed.

@ea-rus ea-rus merged commit fad5ee8 into mindsdb:releases/25.13.0 Dec 11, 2025
31 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Dec 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Query Failure When Joining MongoDB and MySQL Views in a Unified View

10 participants