In this document we are covering how you can connect to Mongo and another RDBMS (like mysql, oracle, sqlserver etc) and do a crossdb join and create reports.
Pre-requisite :
– Helical Insight (version 5.0) installed
– Apache Drill (version 1.20) installed
Useful links :
https://www.helicalinsight.com/connecting-mongodb-using-apache-drill/
https://www.helicalinsight.com/drill-installation-helical-insight/
NOTE : Above documents might be using different version of apache drill as reference in their explanation, but you must install apache drill version 1.20
Below we have covered details step by step :
- In you drill version 1.20 storage create connection to mongo
URL to access storages : http://localhost:8047/storage
Sample mongo connection as below :
{ "type": "mongo", "connection": "mongodb+srv://USERNAME:PASSWORD@HOSTURL/DBNAME?retryWrites=true&w=majority", "pluginOptimizations": { "supportsProjectPushdown": true, "supportsFilterPushdown": true, "supportsAggregatePushdown": true, "supportsSortPushdown": true, "supportsUnionPushdown": true, "supportsLimitPushdown": true }, "batchSize": 100, "enabled": true }
- In order to make connection with any Relational Database like oracle, mysql, postgres, MS SQL Server. You need to download its relevant JDBC Jar file and need to upload it in the location :
“…..\apache-drill-1.20.0\jars\3rdparty”
NOTE :
“…..\apache-drill-1.20.0\jars\3rdparty”
is drill installation directory of your server / machine.
After adding respective JDBC JAR into mentioned folder, you need to restart service of Apache drill.
- Once drill is up again, you need to create new storage with your RDBMS details. For example, we have given reference of RDBMS mysql db server. We have added storage with name as RDBMS (Name can be anything) and added connection details as below :
{ "type": "jdbc", "driver": "com.mysql.jdbc.Driver", "url": "jdbc:mysql://localhost:3306/DBNAME?enabledTLSProtocols=TLSv1.2", "username": "dbusername", "password": "dbpassword", "writerBatchSize": 10000, "enabled": true }
- Till step 3, we have created 2 connection in our apache drill. 1 with mongo (NOSQL) and 1 with RDBMS (SQL). So all work is done from apache drill side.
- Now we will make connection of apache drill with our Helical Insight application. In order to do that login into HI application and go to page : http://YOURIP_ADDRESS_OR_HOST:8085/hi-ee/#/datasource/all
- On this page you will see icon of Apache drill. Make connection of your drill server with HI application. Sample screenshot as below :
- On top of this drill connection, create a metadata.
- In this metadata you will see list of all databases available in your mongo as well as RDBMS (in our case mysql)
- Expand any of the database either from mongo or from RDBMS
- You will see respective collections or tables of that database.
- Select tables / collections which are required to create report and add those into metadata.
NOTE: Based on the kind of version of Helical Insight you are using you might need to follow some additional steps. If you are using any version above Helical Insight version 4.1, then follow below.
Go to defaults.properties located at …/hi/hi-repository/System/Admin/. And can change default from strict-metadata on line no 68 and 70 so that your custom columns and other things work as is. Then restart the server.
-
Now if you have selected tables from Mongo then create view of RDBMS and vice versa. I.e. if RDBMS tables are selected as part of metadata then create view using mongo.
NOTE : In metadata view which you will create, you can simply select everything I.e select * from TABLE
- Join your normal selected tables with views within metadata based on common criteria I.e. primary key and foreign key
- Save the metadata which is created from normal table and views. View and normal tables are joined.
- Create report on top of this metadata, the report can fetch some columns from RDBMS and some columns from mongo as both are joined at metadata level.