-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4242 from szarnyasg/landing-page-queries
Rework queries on the landing page
- Loading branch information
Showing
6 changed files
with
31 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
// Using the appender for bulk inserts | ||
DuckDBConnection conn = (DuckDBConnection) DriverManager.getConnection("jdbc:duckdb:"); | ||
Statement stmt = conn.createStatement(); | ||
stmt.execute("CREATE TABLE person (first_name VARCHAR, last_name VARCHAR, age INT)"); | ||
// Perform bulk inserts using the Appender API | ||
DuckDBConnection conn = (DuckDBConnection) | ||
DriverManager.getConnection("jdbc:duckdb:"); | ||
Statement st = conn.createStatement(); | ||
st.execute("CREATE TABLE person (name VARCHAR, age INT)"); | ||
|
||
try (var appender = conn.createAppender( | ||
DuckDBConnection.DEFAULT_SCHEMA, "tbl" | ||
)) { | ||
appender.beginRow(); | ||
appender.append("John"); | ||
appender.append("Smith"); | ||
appender.append(42); | ||
appender.endRow(); | ||
} | ||
var appender = conn.createAppender( | ||
DuckDBConnection.DEFAULT_SCHEMA, "person"); | ||
|
||
appender.beginRow(); | ||
appender.append("MC Ducky"); | ||
appender.append(49); | ||
appender.endRow(); | ||
appender.close(); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
// Get a list of train stations by traffic | ||
Connection conn = | ||
DriverManager.getConnection("jdbc:duckdb:"); | ||
Statement stmt = conn.createStatement(); | ||
ResultSet rs = stmt.executeQuery( | ||
"SELECT station_name, count(*) AS num_services\n" + | ||
"FROM train_services\n" + | ||
"GROUP BY ALL\n" + | ||
Statement st = conn.createStatement(); | ||
ResultSet rs = st.executeQuery( | ||
"SELECT station_name, count(*) AS num_services\n" + | ||
"FROM train_services\n" + | ||
"GROUP BY ALL\n" + | ||
"ORDER BY num_services DESC;"); | ||
|
||
while (rs.next()) { | ||
System.out.println(rs.getString(1)); | ||
System.out.println(rs.getInt(2)); | ||
} | ||
|
||
System.out.println(rs.next()); |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
-- Load CSV file, auto-detecting column name and types | ||
-- Load CSV file to a table. DuckDB auto-detects | ||
-- the CSV's format, column name and types | ||
CREATE TABLE stations AS | ||
FROM 's3://duckdb-blobs/stations.csv'; |
This file contains 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