This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import duckdb | |
import os | |
import logging | |
# Configure basic logging. In production, you may use a more advanced logging configuration. | |
logging.basicConfig(level=logging.INFO) | |
logger = logging.getLogger(__name__) | |
class DuckDBHandler: | |
def __init__(self, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- first query all the users | |
WITH offsets AS (SELECT a.*, | |
EXTRACT(hour FROM ptn.utc_offset) AS utc_offset | |
FROM bootcamp.attendees a | |
JOIN pg_timezone_names ptn ON a.timezone = ptn.name | |
WHERE a.bootcamp_version = 3 | |
AND a.timezone IS NOT NULL | |
AND a.content_delivery = 'Live'::text | |
), | |
-- then aggregate the users by track and offset, we want matching timezones to fill up first |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For get all of tables size depends on schema there is complex query that show tables splited size (tables , indexes) | |
SELECT | |
schema_name, | |
relname, | |
pg_size_pretty(table_size) AS size, | |
table_size | |
FROM ( | |
SELECT |