-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery_data.py
More file actions
36 lines (28 loc) · 929 Bytes
/
Copy pathquery_data.py
File metadata and controls
36 lines (28 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from metaflow import FlowSpec, pypi, step, card, resources, Flow, S3
class QueryData(FlowSpec):
@resources(memory=16000)
@card
@pypi(packages={"duckdb": "1.4.3", "pandas": "3.0.3"}, python="3.12")
@step
def start(self):
import duckdb # pylint: disable=import-error
import pandas # pylint: disable=import-error
self.files = Flow("PrepareData").latest_successful_run.data.files
with S3() as s3:
objs = s3.get_many(self.files)
paths = [obj.path for obj in objs]
print(f"Found {len(paths)} parquet files")
self.df = duckdb.query(
"""
select * from
read_parquet(?)
limit 100
""",
params=[paths],
).df()
self.next(self.end)
@step
def end(self):
pass
if __name__ == "__main__":
QueryData()