213 words
1 minute
PondPilot with DuckDB Local File Demo

Loading Local DuckDB Files#

This demo loads a preloaded .duckdb file from the server. The file contains main.orders and main.customers tables.

1. Count Orders#

SELECT COUNT(*) AS rows_in_orders FROM main.orders;

2. Preview Orders#

SELECT * FROM main.orders ORDER BY order_id LIMIT 5;

3. Join Orders with Customers#

SELECT 
    o.order_id, 
    o.customer, 
    c.tier, 
    o.amount
FROM main.orders o
JOIN main.customers c USING(customer)
ORDER BY o.order_id;

4. Create New Table will give ERROR#

Create a products table that we’ll use for analysis:

CREATE OR REPLACE TABLE products AS
SELECT * FROM (VALUES
    (1, 'Widget', 29.99),
    (2, 'Gadget', 49.50),
    (3, 'Doohickey', 15.00),
    (4, 'Thingamajig', 99.95),
    (5, 'Whatsit', 10.00)
) AS t(product_id, product_name, price);

SELECT * FROM products;

5. Join New Table with Existing Data#

Join the newly created products table with orders (matching by amount to product price):

SELECT 
    o.order_id,
    o.customer,
    c.tier,
    p.product_name,
    o.amount as price
FROM main.orders o
JOIN main.customers c USING(customer)
JOIN products p ON o.amount = p.price
ORDER BY o.order_id;
SELECT
o.order_id,
o.customer,
c.tier,
p.product_name,
o.amount as price
FROM main.orders o
JOIN main.customers c USING(customer)
JOIN products p ON o.amount = p.price
ORDER BY o.order_id;
PowerShell Profile.ps1
# Without overriding, this would be a terminal frame
function Watch-Tail { Get-Content -Tail 20 -Wait $args }
New-Alias tail Watch-Tail

Note: All widgets on this page share the same DuckDB instance. Tables created in one widget (like products) are accessible in all other widgets!

PondPilot with DuckDB Local File Demo
https://aneeqasif.github.io/posts/pondpilot-duckdb-demo/
Author
Aneeq Asif Azad
Published at
2024-11-04
License
CC BY-NC-SA 4.0