blob: 4b00e427e7d18852cc6636a188e1af735771dce4 [file] [log] [blame]
"use strict";(self.webpackChunkdocs_v_2=self.webpackChunkdocs_v_2||[]).push([[8718],{3905:(e,t,n)=>{n.d(t,{Zo:()=>c,kt:()=>h});var a=n(67294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?i(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e,t){if(null==e)return{};var n,a,r=function(e,t){if(null==e)return{};var n,a,r={},i=Object.keys(e);for(a=0;a<i.length;a++)n=i[a],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)n=i[a],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var p=a.createContext({}),s=function(e){var t=a.useContext(p),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},c=function(e){var t=s(e.components);return a.createElement(p.Provider,{value:t},e.children)},u="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},m=a.forwardRef((function(e,t){var n=e.components,r=e.mdxType,i=e.originalType,p=e.parentName,c=l(e,["components","mdxType","originalType","parentName"]),u=s(n),m=r,h=u["".concat(p,".").concat(m)]||u[m]||d[m]||i;return n?a.createElement(h,o(o({ref:t},c),{},{components:n})):a.createElement(h,o({ref:t},c))}));function h(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var i=n.length,o=new Array(i);o[0]=m;var l={};for(var p in t)hasOwnProperty.call(t,p)&&(l[p]=t[p]);l.originalType=e,l[u]="string"==typeof e?e:r,o[1]=l;for(var s=2;s<i;s++)o[s]=n[s];return a.createElement.apply(null,o)}return a.createElement.apply(null,n)}m.displayName="MDXCreateElement"},3457:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>p,contentTitle:()=>o,default:()=>d,frontMatter:()=>i,metadata:()=>l,toc:()=>s});var a=n(83117),r=(n(67294),n(3905));const i={title:"Trino",hide_title:!0,sidebar_position:34,version:1},o=void 0,l={unversionedId:"databases/trino",id:"databases/trino",title:"Trino",description:"Trino",source:"@site/docs/databases/trino.mdx",sourceDirName:"databases",slug:"/databases/trino",permalink:"/docs/databases/trino",draft:!1,editUrl:"https://github.com/apache/superset/tree/master/docs/docs/databases/trino.mdx",tags:[],version:"current",sidebarPosition:34,frontMatter:{title:"Trino",hide_title:!0,sidebar_position:34,version:1},sidebar:"tutorialSidebar",previous:{title:"Hologres",permalink:"/docs/databases/hologres"},next:{title:"Rockset",permalink:"/docs/databases/rockset"}},p={},s=[{value:"Trino",id:"trino",level:2},{value:"Connection String",id:"connection-string",level:3},{value:"Authentications",id:"authentications",level:3},{value:"1. Basic Authentication",id:"1-basic-authentication",level:4},{value:"2. Kerberos Authentication",id:"2-kerberos-authentication",level:4},{value:"3. Certificate Authentication",id:"3-certificate-authentication",level:4},{value:"4. JWT Authentication",id:"4-jwt-authentication",level:4},{value:"5. Custom Authentication",id:"5-custom-authentication",level:4}],c={toc:s},u="wrapper";function d(e){let{components:t,...n}=e;return(0,r.kt)(u,(0,a.Z)({},c,n,{components:t,mdxType:"MDXLayout"}),(0,r.kt)("h2",{id:"trino"},"Trino"),(0,r.kt)("p",null,"Supported trino version 352 and higher"),(0,r.kt)("h3",{id:"connection-string"},"Connection String"),(0,r.kt)("p",null,"The connection string format is as follows:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre"},"trino://{username}:{password}@{hostname}:{port}/{catalog}\n")),(0,r.kt)("p",null,"If you are running Trino with docker on local machine, please use the following connection URL"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre"},"trino://trino@host.docker.internal:8080\n")),(0,r.kt)("h3",{id:"authentications"},"Authentications"),(0,r.kt)("h4",{id:"1-basic-authentication"},"1. Basic Authentication"),(0,r.kt)("p",null,"You can provide ",(0,r.kt)("inlineCode",{parentName:"p"},"username"),"/",(0,r.kt)("inlineCode",{parentName:"p"},"password")," in the connection string or in the ",(0,r.kt)("inlineCode",{parentName:"p"},"Secure Extra")," field at ",(0,r.kt)("inlineCode",{parentName:"p"},"Advanced / Security")),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},"In Connection String"),(0,r.kt)("pre",{parentName:"li"},(0,r.kt)("code",{parentName:"pre"},"trino://{username}:{password}@{hostname}:{port}/{catalog}\n"))),(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("p",{parentName:"li"},"In ",(0,r.kt)("inlineCode",{parentName:"p"},"Secure Extra")," field"),(0,r.kt)("pre",{parentName:"li"},(0,r.kt)("code",{parentName:"pre",className:"language-json"},'{\n "auth_method": "basic",\n "auth_params": {\n "username": "<username>",\n "password": "<password>"\n }\n}\n')))),(0,r.kt)("p",null,"NOTE: if both are provided, ",(0,r.kt)("inlineCode",{parentName:"p"},"Secure Extra")," always takes higher priority."),(0,r.kt)("h4",{id:"2-kerberos-authentication"},"2. Kerberos Authentication"),(0,r.kt)("p",null,"In ",(0,r.kt)("inlineCode",{parentName:"p"},"Secure Extra")," field, config as following example:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-json"},'{\n "auth_method": "kerberos",\n "auth_params": {\n "service_name": "superset",\n "config": "/path/to/krb5.config",\n ...\n }\n}\n')),(0,r.kt)("p",null,"All fields in ",(0,r.kt)("inlineCode",{parentName:"p"},"auth_params")," are passed directly to the ",(0,r.kt)("a",{parentName:"p",href:"https://github.com/trinodb/trino-python-client/blob/0.306.0/trino/auth.py#L40"},(0,r.kt)("inlineCode",{parentName:"a"},"KerberosAuthentication"))," class."),(0,r.kt)("p",null,"NOTE: Kerberos authentication requires installing the ",(0,r.kt)("a",{parentName:"p",href:"https://github.com/trinodb/trino-python-client"},(0,r.kt)("inlineCode",{parentName:"a"},"trino-python-client"))," locally with either the ",(0,r.kt)("inlineCode",{parentName:"p"},"all")," or ",(0,r.kt)("inlineCode",{parentName:"p"},"kerberos")," optional features, i.e., installing ",(0,r.kt)("inlineCode",{parentName:"p"},"trino[all]")," or ",(0,r.kt)("inlineCode",{parentName:"p"},"trino[kerberos]")," respectively."),(0,r.kt)("h4",{id:"3-certificate-authentication"},"3. Certificate Authentication"),(0,r.kt)("p",null,"In ",(0,r.kt)("inlineCode",{parentName:"p"},"Secure Extra")," field, config as following example:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-json"},'{\n "auth_method": "certificate",\n "auth_params": {\n "cert": "/path/to/cert.pem",\n "key": "/path/to/key.pem"\n }\n}\n')),(0,r.kt)("p",null,"All fields in ",(0,r.kt)("inlineCode",{parentName:"p"},"auth_params")," are passed directly to the ",(0,r.kt)("a",{parentName:"p",href:"https://github.com/trinodb/trino-python-client/blob/0.315.0/trino/auth.py#L416"},(0,r.kt)("inlineCode",{parentName:"a"},"CertificateAuthentication"))," class."),(0,r.kt)("h4",{id:"4-jwt-authentication"},"4. JWT Authentication"),(0,r.kt)("p",null,"Config ",(0,r.kt)("inlineCode",{parentName:"p"},"auth_method")," and provide token in ",(0,r.kt)("inlineCode",{parentName:"p"},"Secure Extra")," field"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-json"},'{\n "auth_method": "jwt",\n "auth_params": {\n "token": "<your-jwt-token>"\n }\n}\n')),(0,r.kt)("h4",{id:"5-custom-authentication"},"5. Custom Authentication"),(0,r.kt)("p",null,"To use custom authentication, first you need to add it into\n",(0,r.kt)("inlineCode",{parentName:"p"},"ALLOWED_EXTRA_AUTHENTICATIONS")," allow list in Superset config file:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-python"},'from your.module import AuthClass\nfrom another.extra import auth_method\n\nALLOWED_EXTRA_AUTHENTICATIONS: Dict[str, Dict[str, Callable[..., Any]]] = {\n "trino": {\n "custom_auth": AuthClass,\n "another_auth_method": auth_method,\n },\n}\n')),(0,r.kt)("p",null,"Then in ",(0,r.kt)("inlineCode",{parentName:"p"},"Secure Extra")," field:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-json"},'{\n "auth_method": "custom_auth",\n "auth_params": {\n ...\n }\n}\n')),(0,r.kt)("p",null,"You can also use custom authentication by providing reference to your ",(0,r.kt)("inlineCode",{parentName:"p"},"trino.auth.Authentication")," class\nor factory function (which returns an ",(0,r.kt)("inlineCode",{parentName:"p"},"Authentication")," instance) to ",(0,r.kt)("inlineCode",{parentName:"p"},"auth_method"),"."),(0,r.kt)("p",null,"All fields in ",(0,r.kt)("inlineCode",{parentName:"p"},"auth_params")," are passed directly to your class/function."),(0,r.kt)("p",null,(0,r.kt)("strong",{parentName:"p"},"Reference"),":"),(0,r.kt)("ul",null,(0,r.kt)("li",{parentName:"ul"},(0,r.kt)("a",{parentName:"li",href:"https://trino.io/episodes/12.html"},"Trino-Superset-Podcast"))))}d.isMDXComponent=!0}}]);