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 2 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
32 changes: 32 additions & 0 deletions sql-odbc/docs/user/power_bi_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,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:
```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
Binary file not shown.