jialuoyang commited on
Commit
6ded3d3
·
verified ·
1 Parent(s): 28f3a79

Verify public loaders and use cached Parquet in DuckDB example

Browse files
Files changed (3) hide show
  1. README.md +10 -7
  2. examples/load.py +5 -4
  3. stats/summary.json +12 -1
README.md CHANGED
@@ -132,15 +132,18 @@ print(next(iter(comments)))
132
 
133
  ```python
134
  import duckdb
 
 
 
 
 
 
 
135
  con = duckdb.connect()
136
- con.execute("INSTALL httpfs; LOAD httpfs;")
137
- con.sql("""
138
  SELECT id, link_id, parent_id, depth
139
- FROM read_parquet(
140
- 'hf://datasets/mashu-data/reddit-comments-sample/data/comments/subreddit=LocalLLaMA/*.parquet',
141
- hive_partitioning=false
142
- ) LIMIT 20
143
- """).show()
144
  ```
145
 
146
  ## Full dataset and custom delivery
 
132
 
133
  ```python
134
  import duckdb
135
+ from huggingface_hub import hf_hub_download
136
+
137
+ path = hf_hub_download(
138
+ repo_id="mashu-data/reddit-comments-sample",
139
+ repo_type="dataset",
140
+ filename="data/comments/subreddit=LocalLLaMA/part-0.parquet",
141
+ )
142
  con = duckdb.connect()
143
+ con.execute("""
 
144
  SELECT id, link_id, parent_id, depth
145
+ FROM read_parquet(?, hive_partitioning=false) LIMIT 20
146
+ """, [path]).df()
 
 
 
147
  ```
148
 
149
  ## Full dataset and custom delivery
examples/load.py CHANGED
@@ -1,4 +1,4 @@
1
- """Run ONE example after the first real Parquet release; dependencies run in Docker."""
2
  import argparse
3
 
4
 
@@ -19,10 +19,11 @@ def main():
19
  print(comments[['id', 'link_id', 'parent_id', 'depth']].head())
20
  else:
21
  import duckdb
22
- # httpfs handles hf:// paths; run in a Docker environment with network access.
 
 
 
23
  conn = duckdb.connect()
24
- conn.execute('INSTALL httpfs; LOAD httpfs;')
25
- path = f'hf://datasets/{args.repo}/data/comments/subreddit=LocalLLaMA/*.parquet'
26
  rows = conn.execute('SELECT id, link_id, parent_id, depth FROM read_parquet(?, hive_partitioning=false) LIMIT 20', [path]).fetchall()
27
  print(rows)
28
 
 
1
+ """Run one loader for the published sample; dependencies run in Docker."""
2
  import argparse
3
 
4
 
 
19
  print(comments[['id', 'link_id', 'parent_id', 'depth']].head())
20
  else:
21
  import duckdb
22
+ from huggingface_hub import hf_hub_download
23
+ # Download one shard to the HF cache, then query the local Parquet file.
24
+ path = hf_hub_download(repo_id=args.repo, repo_type='dataset',
25
+ filename='data/comments/subreddit=LocalLLaMA/part-0.parquet')
26
  conn = duckdb.connect()
 
 
27
  rows = conn.execute('SELECT id, link_id, parent_id, depth FROM read_parquet(?, hive_partitioning=false) LIMIT 20', [path]).fetchall()
28
  print(rows)
29
 
stats/summary.json CHANGED
@@ -205,5 +205,16 @@
205
  "pandas",
206
  "duckdb"
207
  ],
208
- "manual_comment_sample_count": 24
 
 
 
 
 
 
 
 
 
 
 
209
  }
 
205
  "pandas",
206
  "duckdb"
207
  ],
208
+ "manual_comment_sample_count": 24,
209
+ "remote_readers_verified": [
210
+ "datasets",
211
+ "pandas",
212
+ "duckdb"
213
+ ],
214
+ "viewer_configs_verified": [
215
+ "posts",
216
+ "comments"
217
+ ],
218
+ "validated_data_revision": "28f3a79a323cbb994f55c04481a1c87551f5c315",
219
+ "duckdb_loading_method": "Download one public HF shard to the local cache, then query it with DuckDB."
220
  }