Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

ODBC: Add PBIDS support #676

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file modified sql-odbc/docs/user/img/pbi_service_cluster_setting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions sql-odbc/docs/user/power_bi_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* [Open Distro for Elasticsearch](https://opendistro.github.io/for-elasticsearch-docs/docs/install/)
* [Open Distro for Elasticsearch SQL ODBC driver](https://opendistro.github.io/for-elasticsearch-docs/docs/sql/odbc/)
* [OdfeSqlOdbcPBIConnector.mez](../../src/PowerBIConnector/bin/Release/)
* Optional: [odfesqlodbc_import.pbids](../../src/PowerBIConnector/PBIDSExamples) to help with repeated connections to the same server

## Setup
* Copy `OdfeSqlOdbcPBIConnector.mez` file in the `<User>\Documents\Power BI Desktop\Custom Connectors\` folder. This will let Power BI access custom connector.
Expand Down Expand Up @@ -51,6 +52,38 @@

<img src="img/pbi_simple_graph.png">

## Using .PBIDS Files

More info: https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-data-sources#using-pbids-files-to-get-data

Example PBIDS file for Open Distro for Elasticsearch: (available here: [odfesqlodbc_import.pbids](../../src/PowerBIConnector/PBIDSExamples/odfesqlodbc_import.pbids))
```json
{
"version": "0.1",
"connections": [
{
"details": {
"protocol": "odfesqlodbc",
"address": {
"server": "localhost:9200"
}
},
"mode": "Import"
}
]
}
```

The only part you should change is the `server` attribute, to point to the location of your ODFE server.
* For AWS connections, this will be the full path of your ODFE instance (ex: `https://aws-odfe-instance.us-west-1.com`).
* Otherwise, this will be the `host:port` combination for your instance (ex: `localhost:9200`).

Save this as a `.pbids` file. Double-click on it to open up your connection in Power BI Desktop.
It will take you straight to the **Navigator** window for selecting the tables from the ODFE server.
* If this is the first time you are connecting to this instance, you will be prompted for your credentials.

<img src="img/pbi_auth.png" width="500">

## Troubleshooting

* If you get an following error, please install [Open Distro For Elasticsearch SQL ODBC Driver](https://opendistro.github.io/for-elasticsearch-docs/docs/sql/odbc/).
Expand Down
15 changes: 14 additions & 1 deletion sql-odbc/src/PowerBIConnector/OdfeSqlOdbcPBIConnector.pq
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ OnOdbcError = (errorRecord as record) =>
if IsDriverNotInstalled then
error Error.Record("", "The Open Distro For Elasticsearch SQL ODBC driver is not installed. Please install the driver")
else if IsHostUnreachable then
error Error.Record("", "Couldn't reach server. Please double-check the server and auth. " & ConnectionServer)
error Error.Record("", "Couldn't reach server. Please double-check the server and auth. [" & ConnectionServer & "]")
else
error errorRecord;

Expand Down Expand Up @@ -179,6 +179,19 @@ OdfeSqlOdbcPBIConnector = [
]
],

// PBIDS Handler
DSRHandlers = [
#"odfesqlodbc" = [
GetDSR = (server, schema, object, optional options) => [ protocol = "odfesqlodbc", address = [ server = server ] ],
GetFormula = (dsr, optional options) => () =>
let
db = OdfeSqlOdbcPBIConnector.Contents(dsr[address][server])
in
db,
GetFriendlyName = (dsr) => "ODFE SQL ODBC"
]
],

// Enable Encryption
SupportsEncryption = true,

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"version": "0.1",
"connections": [
{
"details": {
"protocol": "odfesqlodbc",
"address": {
"server": "localhost:9200"
}
},
"mode": "Import"
}
]
}
Binary file not shown.