
About this notebook
This notebook queries a Hacker News sample dataset stored in MotherDuck, a cloud DuckDB service. The notebook uses marimo, DuckDB, and Altair. It runs SQL against the table sample_data.hn.hacker_news. One query returns the top 20 domains shared on Hacker News. Another query finds the most commented story for each month. marimo names each query result as a dataframe. Python code then reads those dataframes to draw bar charts.
The notebook adds UI elements to parameterize the SQL. A month multiselect chooses which months to include. A dropdown selects the Hacker News item type, such as story. A text input accepts a search keyword, and the default value is "duckdb". When you change an input, marimo runs the query again. The Altair charts then update. One chart shows the most voted item for each month. Another chart shows monthly mentions of the keyword. If the keyword returns no rows, the notebook stops and shows a message.
The notebook attaches a remote MotherDuck database with the md: prefix. It reads a MotherDuck token from the environment variable motherduck_token or MOTHERDUCK_TOKEN. If no token exists, the notebook shows instructions to create one. The shared sample database attaches without a personal token.

