import{s as te,n as se,o as ae}from"../chunks/scheduler.d6170356.js";import{S as le,i as ne,g as p,s as l,r as M,A as ie,h as r,f as s,c as n,j as K,u as T,x as $,k as ee,y as pe,a,v as U,d as _,t as J,w as G}from"../chunks/index.fcd4cc08.js";import{C as I}from"../chunks/CodeBlock.7b16bdef.js";import{H as re,E as me}from"../chunks/EditOnGithub.da2b595c.js";function oe(P){let i,S,Z,R,m,H,o,Q=`<a href="https://github.com/duckdb/duckdb" rel="nofollow">DuckDB</a> is an in-process SQL <a href="https://en.wikipedia.org/wiki/Online_analytical_processing" rel="nofollow">OLAP</a> database management system.
Since it supports <a href="https://filesystem-spec.readthedocs.io" rel="nofollow">fsspec</a> to read and write remote data, you can use the Hugging Face paths (<a href="https://huggingface.co/docs/huggingface_hub/guides/hf_file_system#integrations" rel="nofollow"><code>hf://</code></a>) to read and write data on the Hub:`,C,c,B='First you need to <a href="../huggingface_hub/quick-start#login">Login with your Hugging Face account</a>, for example using:',F,h,Y,d,z='Then you can <a href="../huggingface_hub/quick-start#create-a-repository">Create a dataset repository</a>, for example using:',x,u,V,f,A='Finally, you can use [Hugging Face paths](<a href="https://huggingface.co/docs/huggingface_hub/guides/hf_file_system#integrations" rel="nofollow">Hugging Face paths</a>) in DuckDB:',X,g,v,y,D=`This creates a file <code>data.parquet</code> in the dataset repository <code>username/my_dataset</code> containing your dataset in Parquet format.
You can reload it later:`,N,k,E,b,O='To have more information on the Hugging Face paths and how they are implemented, please refer to the <a href="https://huggingface.co/docs/huggingface_hub/guides/hf_file_system" rel="nofollow">the client library’s documentation on the HfFileSystem</a>.',q,w,L,j,W;return m=new re({props:{title:"DuckDB",local:"duckdb",headingTag:"h1"}}),h=new I({props:{code:"aHVnZ2luZ2ZhY2UtY2xpJTIwbG9naW4=",highlighted:'huggingface-<span class="hljs-keyword">cli</span> login',wrap:!1}}),u=new I({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEhmQXBpJTBBJTBBSGZBcGkoKS5jcmVhdGVfcmVwbyhyZXBvX2lkJTNEJTIydXNlcm5hbWUlMkZteV9kYXRhc2V0JTIyJTJDJTIwcmVwb190eXBlJTNEJTIyZGF0YXNldCUyMik=",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> HfApi

HfApi().create_repo(repo_id=<span class="hljs-string">&quot;username/my_dataset&quot;</span>, repo_type=<span class="hljs-string">&quot;dataset&quot;</span>)`,wrap:!1}}),g=new I({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEhmRmlsZVN5c3RlbSUwQWltcG9ydCUyMGR1Y2tkYiUwQSUwQWZzJTIwJTNEJTIwSGZGaWxlU3lzdGVtKCklMEFkdWNrZGIucmVnaXN0ZXJfZmlsZXN5c3RlbShmcyklMEFkdWNrZGIuc3FsKCUyMkNPUFklMjB0YmwlMjBUTyUyMCdoZiUzQSUyRiUyRmRhdGFzZXRzJTJGdXNlcm5hbWUlMkZteV9kYXRhc2V0JTJGZGF0YS5wYXJxdWV0JyUyMChGT1JNQVQlMjBQQVJRVUVUKSUzQiUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> HfFileSystem
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> duckdb

<span class="hljs-meta">&gt;&gt;&gt; </span>fs = HfFileSystem()
<span class="hljs-meta">&gt;&gt;&gt; </span>duckdb.register_filesystem(fs)
<span class="hljs-meta">&gt;&gt;&gt; </span>duckdb.sql(<span class="hljs-string">&quot;COPY tbl TO &#x27;hf://datasets/username/my_dataset/data.parquet&#x27; (FORMAT PARQUET);&quot;</span>)`,wrap:!1}}),k=new I({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEhmRmlsZVN5c3RlbSUwQWltcG9ydCUyMGR1Y2tkYiUwQSUwQWZzJTIwJTNEJTIwSGZGaWxlU3lzdGVtKCklMEFkdWNrZGIucmVnaXN0ZXJfZmlsZXN5c3RlbShmcyklMEFkZiUyMCUzRCUyMGR1Y2tkYi5xdWVyeSglMjJTRUxFQ1QlMjAqJTIwRlJPTSUyMCdoZiUzQSUyRiUyRmRhdGFzZXRzJTJGdXNlcm5hbWUlMkZteV9kYXRhc2V0JTJGZGF0YS5wYXJxdWV0JyUyMExJTUlUJTIwMTAlM0IlMjIpLmRmKCk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> HfFileSystem
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> duckdb

<span class="hljs-meta">&gt;&gt;&gt; </span>fs = HfFileSystem()
<span class="hljs-meta">&gt;&gt;&gt; </span>duckdb.register_filesystem(fs)
<span class="hljs-meta">&gt;&gt;&gt; </span>df = duckdb.query(<span class="hljs-string">&quot;SELECT * FROM &#x27;hf://datasets/username/my_dataset/data.parquet&#x27; LIMIT 10;&quot;</span>).df()`,wrap:!1}}),w=new me({props:{source:"https://github.com/huggingface/hub-docs/blob/main/docs/hub/datasets-duckdb.md"}}),{c(){i=p("meta"),S=l(),Z=p("p"),R=l(),M(m.$$.fragment),H=l(),o=p("p"),o.innerHTML=Q,C=l(),c=p("p"),c.innerHTML=B,F=l(),M(h.$$.fragment),Y=l(),d=p("p"),d.innerHTML=z,x=l(),M(u.$$.fragment),V=l(),f=p("p"),f.innerHTML=A,X=l(),M(g.$$.fragment),v=l(),y=p("p"),y.innerHTML=D,N=l(),M(k.$$.fragment),E=l(),b=p("p"),b.innerHTML=O,q=l(),M(w.$$.fragment),L=l(),j=p("p"),this.h()},l(e){const t=ie("svelte-u9bgzb",document.head);i=r(t,"META",{name:!0,content:!0}),t.forEach(s),S=n(e),Z=r(e,"P",{}),K(Z).forEach(s),R=n(e),T(m.$$.fragment,e),H=n(e),o=r(e,"P",{"data-svelte-h":!0}),$(o)!=="svelte-16upv1p"&&(o.innerHTML=Q),C=n(e),c=r(e,"P",{"data-svelte-h":!0}),$(c)!=="svelte-1hbzj8b"&&(c.innerHTML=B),F=n(e),T(h.$$.fragment,e),Y=n(e),d=r(e,"P",{"data-svelte-h":!0}),$(d)!=="svelte-1tu70ef"&&(d.innerHTML=z),x=n(e),T(u.$$.fragment,e),V=n(e),f=r(e,"P",{"data-svelte-h":!0}),$(f)!=="svelte-8tw6zv"&&(f.innerHTML=A),X=n(e),T(g.$$.fragment,e),v=n(e),y=r(e,"P",{"data-svelte-h":!0}),$(y)!=="svelte-1eb1lq2"&&(y.innerHTML=D),N=n(e),T(k.$$.fragment,e),E=n(e),b=r(e,"P",{"data-svelte-h":!0}),$(b)!=="svelte-1o8dsbk"&&(b.innerHTML=O),q=n(e),T(w.$$.fragment,e),L=n(e),j=r(e,"P",{}),K(j).forEach(s),this.h()},h(){ee(i,"name","hf:doc:metadata"),ee(i,"content",ce)},m(e,t){pe(document.head,i),a(e,S,t),a(e,Z,t),a(e,R,t),U(m,e,t),a(e,H,t),a(e,o,t),a(e,C,t),a(e,c,t),a(e,F,t),U(h,e,t),a(e,Y,t),a(e,d,t),a(e,x,t),U(u,e,t),a(e,V,t),a(e,f,t),a(e,X,t),U(g,e,t),a(e,v,t),a(e,y,t),a(e,N,t),U(k,e,t),a(e,E,t),a(e,b,t),a(e,q,t),U(w,e,t),a(e,L,t),a(e,j,t),W=!0},p:se,i(e){W||(_(m.$$.fragment,e),_(h.$$.fragment,e),_(u.$$.fragment,e),_(g.$$.fragment,e),_(k.$$.fragment,e),_(w.$$.fragment,e),W=!0)},o(e){J(m.$$.fragment,e),J(h.$$.fragment,e),J(u.$$.fragment,e),J(g.$$.fragment,e),J(k.$$.fragment,e),J(w.$$.fragment,e),W=!1},d(e){e&&(s(S),s(Z),s(R),s(H),s(o),s(C),s(c),s(F),s(Y),s(d),s(x),s(V),s(f),s(X),s(v),s(y),s(N),s(E),s(b),s(q),s(L),s(j)),s(i),G(m,e),G(h,e),G(u,e),G(g,e),G(k,e),G(w,e)}}}const ce='{"title":"DuckDB","local":"duckdb","sections":[],"depth":1}';function he(P){return ae(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ye extends le{constructor(i){super(),ne(this,i,he,oe,te,{})}}export{ye as component};
