Skip to content

Commit

Permalink
Update landing page snippets to fit into the box
Browse files Browse the repository at this point in the history
  • Loading branch information
szarnyasg committed Feb 14, 2025
1 parent 31623a4 commit 4292373
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
3 changes: 2 additions & 1 deletion _includes/landing-page/java/appender.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
DuckDBConnection conn = (DuckDBConnection)
DriverManager.getConnection("jdbc:duckdb:");
Statement st = conn.createStatement();
st.execute("CREATE TABLE person (name VARCHAR, age INT)");
st.execute("CREATE TABLE person " +
"(name VARCHAR, age INT)");

var appender = conn.createAppender(
DuckDBConnection.DEFAULT_SCHEMA, "person");
Expand Down
3 changes: 2 additions & 1 deletion _includes/landing-page/java/sql-query.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
DriverManager.getConnection("jdbc:duckdb:");
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(
"SELECT station_name, count(*) AS num_services\n" +
"SELECT station_name, \n" +
" count(*) AS num_services\n" +
"FROM train_services\n" +
"GROUP BY ALL\n" +
"ORDER BY num_services DESC;");
Expand Down
6 changes: 3 additions & 3 deletions _includes/landing-page/python/udf.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Create custom user-defined function
import duckdb

def add_plus_one(x):
def plus_one(x):
return x + 1

con = duckdb.connect()
con.create_function('add_plus_one', add_plus_one,
con.create_function('plus_one', plus_one,
['BIGINT'], 'BIGINT', type='native')

con.sql("""
SELECT sum(add_plus_one(i)) FROM range(10) tbl(i);
SELECT sum(plus_one(i)) FROM range(10) tbl(i);
""")
8 changes: 4 additions & 4 deletions _includes/landing-page/sql/join-full.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ CREATE TABLE distances AS
FROM 's3://duckdb-blobs/distances.parquet';

-- Find the top-3 longest domestic train routes
SELECT s1.name_short, s2.name_short, distances.distance
FROM distances
JOIN stations s1 ON distances.station1 = s1.code
JOIN stations s2 ON distances.station2 = s2.code
SELECT s1.name_short, s2.name_short, d.distance
FROM distances d
JOIN stations s1 ON d.station1 = s1.code
JOIN stations s2 ON d.station2 = s2.code
WHERE s1.country = s2.country
AND s1.code < s2.code
ORDER BY distance DESC
Expand Down
8 changes: 4 additions & 4 deletions _includes/landing-page/sql/join.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-- Find the top-3 longest domestic train routes
SELECT s1.name_short, s2.name_short, distances.distance
FROM distances
JOIN stations s1 ON distances.station1 = s1.code
JOIN stations s2 ON distances.station2 = s2.code
SELECT s1.name_short, s2.name_short, d.distance
FROM distances d
JOIN stations s1 ON d.station1 = s1.code
JOIN stations s2 ON d.station2 = s2.code
WHERE s1.country = s2.country
AND s1.code < s2.code
ORDER BY distance DESC
Expand Down

0 comments on commit 4292373

Please sign in to comment.