blob: 91515e0ca88fd2e83c0dc2df313ef36a33b71ce4 [file] [log] [blame]
(window.webpackJsonp=window.webpackJsonp||[]).push([[66],{EnvW:function(e,t,a){"use strict";a.r(t),a.d(t,"_frontmatter",(function(){return l})),a.d(t,"default",(function(){return b}));var n=a("k1TG"),o=a("8o2o"),r=(a("q1tI"),a("7ljp")),s=a("hhGP"),l=(a("qKvR"),{});void 0!==l&&l&&l===Object(l)&&Object.isExtensible(l)&&!l.hasOwnProperty("__filemeta")&&Object.defineProperty(l,"__filemeta",{configurable:!0,value:{name:"_frontmatter",filename:"src/pages/docs/Miscellaneous/importing-exporting.mdx"}});var c={_frontmatter:l},i=s.a;function b(e){var t=e.components,a=Object(o.a)(e,["components"]);return Object(r.b)(i,Object(n.a)({},c,a,{components:t,mdxType:"MDXLayout"}),Object(r.b)("h2",{id:"importing-and-exporting-datasources"},"Importing and Exporting Datasources"),Object(r.b)("p",null,"The superset cli allows you to import and export datasources from and to YAML. Datasources include\nboth databases and druid clusters. The data is expected to be organized in the following hierarchy:"),Object(r.b)("pre",null,Object(r.b)("code",Object(n.a)({parentName:"pre"},{}),"├──databases\n| ├──database_1\n| | ├──table_1\n| | | ├──columns\n| | | | ├──column_1\n| | | | ├──column_2\n| | | | └──... (more columns)\n| | | └──metrics\n| | | ├──metric_1\n| | | ├──metric_2\n| | | └──... (more metrics)\n| | └── ... (more tables)\n| └── ... (more databases)\n└──druid_clusters\n ├──cluster_1\n | ├──datasource_1\n | | ├──columns\n | | | ├──column_1\n | | | ├──column_2\n | | | └──... (more columns)\n | | └──metrics\n | | ├──metric_1\n | | ├──metric_2\n | | └──... (more metrics)\n | └── ... (more datasources)\n └── ... (more clusters)\n")),Object(r.b)("h3",{id:"exporting-datasources-to-yaml"},"Exporting Datasources to YAML"),Object(r.b)("p",null,"You can print your current datasources to stdout by running:"),Object(r.b)("pre",null,Object(r.b)("code",Object(n.a)({parentName:"pre"},{}),"superset export_datasources\n")),Object(r.b)("p",null,"To save your datasources to a file run:"),Object(r.b)("pre",null,Object(r.b)("code",Object(n.a)({parentName:"pre"},{}),"superset export_datasources -f <filename>\n")),Object(r.b)("p",null,"By default, default (null) values will be omitted. Use the -d flag to include them. If you want back\nreferences to be included (e.g. a column to include the table id it belongs to) use the -b flag."),Object(r.b)("p",null,"Alternatively, you can export datasources using the UI:"),Object(r.b)("ol",null,Object(r.b)("li",{parentName:"ol"},"Open ",Object(r.b)("strong",{parentName:"li"},"Sources -> Databases")," to export all tables associated to a single or multiple databases.\n(",Object(r.b)("strong",{parentName:"li"},"Tables")," for one or more tables, ",Object(r.b)("strong",{parentName:"li"},"Druid Clusters")," for clusters, ",Object(r.b)("strong",{parentName:"li"},"Druid Datasources")," for\ndatasources)"),Object(r.b)("li",{parentName:"ol"},"Select the items you would like to export."),Object(r.b)("li",{parentName:"ol"},"Click ",Object(r.b)("strong",{parentName:"li"},"Actions -> Export")," to YAML"),Object(r.b)("li",{parentName:"ol"},"If you want to import an item that you exported through the UI, you will need to nest it inside\nits parent element, e.g. a database needs to be nested under databases a table needs to be nested\ninside a database element.")),Object(r.b)("p",null,"In order to obtain an ",Object(r.b)("strong",{parentName:"p"},"exhaustive list of all fields")," you can import using the YAML import run:"),Object(r.b)("pre",null,Object(r.b)("code",Object(n.a)({parentName:"pre"},{}),"superset export_datasource_schema\n")),Object(r.b)("p",null,"As a reminder, you can use the ",Object(r.b)("inlineCode",{parentName:"p"},"-b")," flag to include back references."),Object(r.b)("h3",{id:"importing-datasources-from-yaml"},"Importing Datasources from YAML"),Object(r.b)("p",null,"In order to import datasources from a YAML file(s), run:"),Object(r.b)("pre",null,Object(r.b)("code",Object(n.a)({parentName:"pre"},{}),"superset import_datasources -p <path or filename>\n")),Object(r.b)("p",null,"If you supply a path all files ending with ",Object(r.b)("strong",{parentName:"p"},"yaml")," or ",Object(r.b)("strong",{parentName:"p"},"yml")," will be parsed. You can apply\nadditional flags (e.g. to search the supplied path recursively):"),Object(r.b)("pre",null,Object(r.b)("code",Object(n.a)({parentName:"pre"},{}),"superset import_datasources -p <path> -r\n")),Object(r.b)("p",null,"The sync flag ",Object(r.b)("strong",{parentName:"p"},"-s")," takes parameters in order to sync the supplied elements with your file. Be\ncareful this can delete the contents of your meta database. Example:"),Object(r.b)("pre",null,Object(r.b)("code",Object(n.a)({parentName:"pre"},{}),"superset import_datasources -p <path / filename> -s columns,metrics\n")),Object(r.b)("p",null,"This will sync all metrics and columns for all datasources found in the ",Object(r.b)("inlineCode",{parentName:"p"},"<path /filename>")," in the\nSuperset meta database. This means columns and metrics not specified in YAML will be deleted. If you\nwould add tables to columns,metrics those would be synchronised as well."),Object(r.b)("p",null,"If you don’t supply the sync flag (",Object(r.b)("strong",{parentName:"p"},"-s"),") importing will only add and update (override) fields.\nE.g. you can add a verbose_name to the column ds in the table random_time_series from the example\ndatasets by saving the following YAML to file and then running the ",Object(r.b)("strong",{parentName:"p"},"import_datasources")," command."),Object(r.b)("pre",null,Object(r.b)("code",Object(n.a)({parentName:"pre"},{}),"databases:\n- database_name: main\n tables:\n - table_name: random_time_series\n columns:\n - column_name: ds\n verbose_name: datetime\n")))}void 0!==b&&b&&b===Object(b)&&Object.isExtensible(b)&&!b.hasOwnProperty("__filemeta")&&Object.defineProperty(b,"__filemeta",{configurable:!0,value:{name:"MDXContent",filename:"src/pages/docs/Miscellaneous/importing-exporting.mdx"}}),b.isMDXComponent=!0}}]);
//# sourceMappingURL=component---src-pages-docs-miscellaneous-importing-exporting-mdx-424a63a6fa41f621ef28.js.map