jonathanagustin commited on
Commit
a8c4c5f
·
verified ·
1 Parent(s): 4e18ebf

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py CHANGED
@@ -119,6 +119,29 @@ def test_download():
119
  return {"status": "error", "error": str(e), "type": type(e).__name__}
120
 
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  @app.get("/rows/{config}")
123
  def get_rows(
124
  config: str,
 
119
  return {"status": "error", "error": str(e), "type": type(e).__name__}
120
 
121
 
122
+ @app.get("/test-query")
123
+ def test_query():
124
+ """Test querying a parquet file."""
125
+ try:
126
+ path = get_parquet_path("courts")
127
+ conn = duckdb.connect(":memory:")
128
+ conn.execute(f"CREATE VIEW data AS SELECT * FROM read_parquet('{path}')")
129
+ result = conn.execute("SELECT COUNT(*) as cnt FROM data").fetchdf()
130
+ count = int(result['cnt'].iloc[0])
131
+
132
+ # Get one row
133
+ row = conn.execute("SELECT * FROM data LIMIT 1").fetchdf()
134
+ conn.close()
135
+
136
+ # Convert to dict
137
+ row_dict = row.to_dict(orient="records")[0] if len(row) > 0 else {}
138
+
139
+ return {"status": "ok", "count": count, "sample_row_keys": list(row_dict.keys())}
140
+ except Exception as e:
141
+ import traceback
142
+ return {"status": "error", "error": str(e), "type": type(e).__name__, "traceback": traceback.format_exc()}
143
+
144
+
145
  @app.get("/rows/{config}")
146
  def get_rows(
147
  config: str,