blob: 6b3893ad9f184d045707261968e3fc42d6055bfd [file] [log] [blame]
(window.webpackJsonp=window.webpackJsonp||[]).push([[18],{"5qe8":function(e,t,a){"use strict";a.r(t),a.d(t,"_frontmatter",(function(){return r})),a.d(t,"default",(function(){return l}));var n=a("k1TG"),o=a("8o2o"),c=(a("q1tI"),a("7ljp")),b=a("hhGP"),r=(a("qKvR"),{});void 0!==r&&r&&r===Object(r)&&Object.isExtensible(r)&&!r.hasOwnProperty("__filemeta")&&Object.defineProperty(r,"__filemeta",{configurable:!0,value:{name:"_frontmatter",filename:"src/pages/docs/Connecting to Databases/databricks.mdx"}});var i={_frontmatter:r},s=b.a;function l(e){var t=e.components,a=Object(o.a)(e,["components"]);return Object(c.b)(s,Object(n.a)({},i,a,{components:t,mdxType:"MDXLayout"}),Object(c.b)("h2",{id:"databricks"},"Databricks"),Object(c.b)("p",null,"To connect to Databricks, first install ",Object(c.b)("a",Object(n.a)({parentName:"p"},{href:"https://pypi.org/project/databricks-dbapi/"}),"databricks-dbapi")," with the optional SQLAlchemy dependencies:"),Object(c.b)("pre",null,Object(c.b)("code",Object(n.a)({parentName:"pre"},{className:"language-bash"}),"pip install databricks-dbapi[sqlalchemy]\n")),Object(c.b)("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 ",Object(c.b)("a",Object(n.a)({parentName:"p"},{href:"https://docs.databricks.com/sql/admin/sql-endpoints.html"}),"SQL endpoints"),"."),Object(c.b)("h3",{id:"hive"},"Hive"),Object(c.b)("p",null,"To use the Hive connector you need the following information from your cluster:"),Object(c.b)("ul",null,Object(c.b)("li",{parentName:"ul"},"Server hostname"),Object(c.b)("li",{parentName:"ul"},"Port"),Object(c.b)("li",{parentName:"ul"},"HTTP path")),Object(c.b)("p",null,'These can be found under "Configuration" -> "Advanced Options" -> "JDBC/ODBC".'),Object(c.b)("p",null,'You also need an access token from "Settings" -> "User Settings" -> "Access Tokens".'),Object(c.b)("p",null,'Once you have all this information, add a database of type "Databricks (Hive)" in Superset, and use the following SQLAlchemy URI:'),Object(c.b)("pre",null,Object(c.b)("code",Object(n.a)({parentName:"pre"},{}),"databricks+pyhive://token:{access token}@{server hostname}:{port}/{database name}\n")),Object(c.b)("p",null,'You also need to add the following configuration to "Other" -> "Engine Parameters", with your HTTP path:'),Object(c.b)("pre",null,Object(c.b)("code",Object(n.a)({parentName:"pre"},{}),'{"connect_args": {"http_path": "sql/protocolv1/o/****"}}\n')),Object(c.b)("h3",{id:"odbc"},"ODBC"),Object(c.b)("p",null,"For ODBC you first need to install the ",Object(c.b)("a",Object(n.a)({parentName:"p"},{href:"https://databricks.com/spark/odbc-drivers-download"}),"ODBC drivers for your platform"),"."),Object(c.b)("p",null,"For a regular connection use this as the SQLAlchemy URI:"),Object(c.b)("pre",null,Object(c.b)("code",Object(n.a)({parentName:"pre"},{}),"databricks+pyodbc://token:{access token}@{server hostname}:{port}/{database name}\n")),Object(c.b)("p",null,"And for the connection arguments:"),Object(c.b)("pre",null,Object(c.b)("code",Object(n.a)({parentName:"pre"},{}),'{"connect_args": {"http_path": "sql/protocolv1/o/****", "driver_path": "/path/to/odbc/driver"}}\n')),Object(c.b)("p",null,"The driver path should be:"),Object(c.b)("ul",null,Object(c.b)("li",{parentName:"ul"},Object(c.b)("inlineCode",{parentName:"li"},"/Library/simba/spark/lib/libsparkodbc_sbu.dylib")," (Mac OS)"),Object(c.b)("li",{parentName:"ul"},Object(c.b)("inlineCode",{parentName:"li"},"/opt/simba/spark/lib/64/libsparkodbc_sb64.so")," (Linux)")),Object(c.b)("p",null,"For a connection to a SQL endpoint you need to use the HTTP path from the endpoint:"),Object(c.b)("pre",null,Object(c.b)("code",Object(n.a)({parentName:"pre"},{}),'{"connect_args": {"http_path": "/sql/1.0/endpoints/****", "driver_path": "/path/to/odbc/driver"}}\n')))}void 0!==l&&l&&l===Object(l)&&Object.isExtensible(l)&&!l.hasOwnProperty("__filemeta")&&Object.defineProperty(l,"__filemeta",{configurable:!0,value:{name:"MDXContent",filename:"src/pages/docs/Connecting to Databases/databricks.mdx"}}),l.isMDXComponent=!0}}]);
//# sourceMappingURL=component---src-pages-docs-connecting-to-databases-databricks-mdx-8eb0ee82d15d490d1470.js.map