kmularise opened a new pull request, #4987:
URL: https://github.com/apache/zeppelin/pull/4987

   ### What is this PR for?
   This PR introduces the ensureTableFunction() method to enhance compatibility 
with mongosh (MongoDB Shell) in the Apache Zeppelin Mongo interpreter context. 
Previously, the .table() function was attached to DBQuery.prototype, which may 
not be sufficient in newer MongoDB environments where command cursors or 
altered prototypes are used.
   The new method safely injects the .table() utility function into relevant 
cursor prototypes at runtime, ensuring table rendering works as expected even 
under mongosh.
   
   Additionally, the changes:
   
   - Introduce safer prototype extension using a dummy cursor check.
   - Preserve the original behavior for backwards compatibility.
   - Avoid redundant registration in unsupported environments.
   
   
   ### What type of PR is it?
   Bug Fix
   
   ### Todos
   * [x] - Add ensureTableFunction() for dynamic prototype injection
   
   ### What is the Jira issue?
   * [ZEPPELIN-6234](https://issues.apache.org/jira/browse/ZEPPELIN-6234): 
MongoDB interpreter: .table() function not working
   
   ### How should this be tested?
   1. Use Apache Zeppelin with the MongoDB interpreter.
   2. Connect to a MongoDB 8.x instance using mongosh.
   3. Execute a standard query with .table():
   ```js
   db.collection.find().table()
   ```
   
   4. Verify:
   - `%table` format renders properly in Zeppelin UI.
   - No registration or prototype errors occur in shell.
   - Legacy Mongo Shells continue to function as before.
   
   ### Screenshots (if appropriate)
   <img width="510" height="270" alt="Pasted Graphic" 
src="https://github.com/user-attachments/assets/9da70f3e-739a-46fa-819a-b8877de213cc";
 />
   
   ### Questions:
   * Does the license files need to update? No
   * Is there breaking changes for older versions? No. The solution maintains 
backward compatibility.
   * Does this needs documentation? Optional. Could be mentioned in Mongo 
interpreter tips or mongosh compatibility notes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscr...@zeppelin.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to