initial commit
This commit is contained in:
26
verify_zero.py
Normal file
26
verify_zero.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import duckdb
|
||||
import os
|
||||
import json
|
||||
|
||||
DUCKDB_PATH = 'analytics.duckdb'
|
||||
|
||||
def verify_zero_tenant():
|
||||
conn = duckdb.connect(DUCKDB_PATH)
|
||||
try:
|
||||
conn.execute("SET s3_region='sgp1';")
|
||||
conn.execute("SET s3_endpoint='sgp1.digitaloceanspaces.com';")
|
||||
conn.execute("SET s3_url_style='path';")
|
||||
s3_path = 's3://nearle/parquet/deliveries/*.parquet'
|
||||
conn.execute(f"CREATE OR REPLACE VIEW deliveries AS SELECT * FROM read_parquet('{s3_path}', union_by_name = true)")
|
||||
|
||||
# Check values distribution for tenantname
|
||||
res = conn.execute("SELECT tenantname, COUNT(*) FROM deliveries GROUP BY 1 ORDER BY 2 DESC LIMIT 10").df()
|
||||
print(res)
|
||||
|
||||
except Exception as e:
|
||||
print("Error:", e)
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
verify_zero_tenant()
|
||||
Reference in New Issue
Block a user