I first saw
Interactive Polyglot Notebooks in dotnetConf couple of years back. I immediately started thinking about all the possibilities it brings to the table for a developer. It could be used just a place to put all the code snippets by developers, or by Functional Consultants/BA for documentation with just a little code or script sprinkled here and there.
One of the recent capabilities that has been introduced in the ability to import other notebooks. I believe this is such a powerful update for re-useability and also to abstract away all the code for non-developer audience who want to start using Polyglot Notebooks. In order to demonstrate this capability, I have created a repo that shows how to use Polyglot Notebooks as a place to store all your important SQL queries.
The location of the repo is https://github.com/rajyraman/polyglot-notebook-ideas. There are two notebooks that you can look at in this repo.
This notebook demonstrates how to use SQL magic command to connect to the native Dataverse TDS endpoint. Since you are connecting to the native TDS endpoints not all tables will be queryable e.g., customcontrol, importjob, tracelog etc.
This notebook shows you how you can use Mark Carrington‘s SQL 4 CDS library to query Dataverse. Since that is transpiling SQL to FetchXML, queries that cannot be run via the TDS endpoint can be run using this library. Even though the library is very well capable of running DELETEs, INSERTs and UPDATEs I have shown how to handle SELECTs only, because I wanted to demonstrate three things:
- How to use #!import magic command
- How to inject a magic command on the fly
- How to share variables between kernels
Polyglot Notebooks can be either created as .ipynb or .dib. I like the .ipynb format because it also saves the result. I am using notebooks as interactive documentation, so I really love this capability.
I have added this amazing renderer extension called Data Table Renderers by Taras Novak to the extension.json on the repo, so VSCode will ask you to install this extension when you open the repo. I really love this extension as it makes working on CSV and JSON data quite effective with search, sort, data analysis etc.
I hope this post has given you some ideas on how to leverage Polyglot Notebooks in your daily Power Apps/Dynamics 365 workflow. You could even potentially use this as a place to test out all your Power Fx expressions or document the various Power Platform CLI commands you use to train other developers.