blob: 3937e4e88bf3350c535ee47f1d4ae502c2c831f2 [file] [log] [blame]
"use strict";(self.webpackChunkdocs_v_2=self.webpackChunkdocs_v_2||[]).push([[7706],{43335:function(e,t,r){r.r(t),r.d(t,{assets:function(){return p},contentTitle:function(){return c},default:function(){return b},frontMatter:function(){return s},metadata:function(){return l},toc:function(){return d}});var n=r(83117),a=r(80102),o=(r(67294),r(3905)),i=["components"],s={title:"Databricks",hide_title:!0,sidebar_position:37,version:1},c=void 0,l={unversionedId:"databases/databricks",id:"databases/databricks",title:"Databricks",description:"Databricks",source:"@site/docs/databases/databricks.mdx",sourceDirName:"databases",slug:"/databases/databricks",permalink:"/docs/databases/databricks",editUrl:"https://github.com/apache/superset/tree/master/docs/docs/databases/databricks.mdx",tags:[],version:"current",sidebarPosition:37,frontMatter:{title:"Databricks",hide_title:!0,sidebar_position:37,version:1},sidebar:"tutorialSidebar",previous:{title:"CrateDB",permalink:"/docs/databases/cratedb"},next:{title:"Firebird",permalink:"/docs/databases/firebird"}},p={},d=[{value:"Databricks",id:"databricks",level:2},{value:"Hive",id:"hive",level:3},{value:"ODBC",id:"odbc",level:3}],u={toc:d};function b(e){var t=e.components,r=(0,a.Z)(e,i);return(0,o.kt)("wrapper",(0,n.Z)({},u,r,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h2",{id:"databricks"},"Databricks"),(0,o.kt)("p",null,"To connect to Databricks, first install ",(0,o.kt)("a",{parentName:"p",href:"https://pypi.org/project/databricks-dbapi/"},"databricks-dbapi")," with the optional SQLAlchemy dependencies:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-bash"},"pip install databricks-dbapi[sqlalchemy]\n")),(0,o.kt)("p",null,"There are two ways to connect to Databricks: using a Hive connector or an ODBC connector. Both ways work similarly, but only ODBC can be used to connect to ",(0,o.kt)("a",{parentName:"p",href:"https://docs.databricks.com/sql/admin/sql-endpoints.html"},"SQL endpoints"),"."),(0,o.kt)("h3",{id:"hive"},"Hive"),(0,o.kt)("p",null,"To use the Hive connector you need the following information from your cluster:"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"Server hostname"),(0,o.kt)("li",{parentName:"ul"},"Port"),(0,o.kt)("li",{parentName:"ul"},"HTTP path")),(0,o.kt)("p",null,'These can be found under "Configuration" -> "Advanced Options" -> "JDBC/ODBC".'),(0,o.kt)("p",null,'You also need an access token from "Settings" -> "User Settings" -> "Access Tokens".'),(0,o.kt)("p",null,'Once you have all this information, add a database of type "Databricks (Hive)" in Superset, and use the following SQLAlchemy URI:'),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre"},"databricks+pyhive://token:{access token}@{server hostname}:{port}/{database name}\n")),(0,o.kt)("p",null,'You also need to add the following configuration to "Other" -> "Engine Parameters", with your HTTP path:'),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre"},'{"connect_args": {"http_path": "sql/protocolv1/o/****"}}\n')),(0,o.kt)("h3",{id:"odbc"},"ODBC"),(0,o.kt)("p",null,"For ODBC you first need to install the ",(0,o.kt)("a",{parentName:"p",href:"https://databricks.com/spark/odbc-drivers-download"},"ODBC drivers for your platform"),"."),(0,o.kt)("p",null,"For a regular connection use this as the SQLAlchemy URI:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre"},"databricks+pyodbc://token:{access token}@{server hostname}:{port}/{database name}\n")),(0,o.kt)("p",null,"And for the connection arguments:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre"},'{"connect_args": {"http_path": "sql/protocolv1/o/****", "driver_path": "/path/to/odbc/driver"}}\n')),(0,o.kt)("p",null,"The driver path should be:"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"/Library/simba/spark/lib/libsparkodbc_sbu.dylib")," (Mac OS)"),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"/opt/simba/spark/lib/64/libsparkodbc_sb64.so")," (Linux)")),(0,o.kt)("p",null,"For a connection to a SQL endpoint you need to use the HTTP path from the endpoint:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre"},'{"connect_args": {"http_path": "/sql/1.0/endpoints/****", "driver_path": "/path/to/odbc/driver"}}\n')))}b.isMDXComponent=!0},3905:function(e,t,r){r.d(t,{Zo:function(){return p},kt:function(){return b}});var n=r(67294);function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?o(Object(r),!0).forEach((function(t){a(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function s(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}var c=n.createContext({}),l=function(e){var t=n.useContext(c),r=t;return e&&(r="function"==typeof e?e(t):i(i({},t),e)),r},p=function(e){var t=l(e.components);return n.createElement(c.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return n.createElement(n.Fragment,{},t)}},u=n.forwardRef((function(e,t){var r=e.components,a=e.mdxType,o=e.originalType,c=e.parentName,p=s(e,["components","mdxType","originalType","parentName"]),u=l(r),b=a,k=u["".concat(c,".").concat(b)]||u[b]||d[b]||o;return r?n.createElement(k,i(i({ref:t},p),{},{components:r})):n.createElement(k,i({ref:t},p))}));function b(e,t){var r=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var o=r.length,i=new Array(o);i[0]=u;var s={};for(var c in t)hasOwnProperty.call(t,c)&&(s[c]=t[c]);s.originalType=e,s.mdxType="string"==typeof e?e:a,i[1]=s;for(var l=2;l<o;l++)i[l]=r[l];return n.createElement.apply(null,i)}return n.createElement.apply(null,r)}u.displayName="MDXCreateElement"}}]);