-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: struct, list, and map parameter support #30
Conversation
@Mause , any idea on when this will be released? |
It will be included in the next DuckDB release |
Hi @Mause, I was excited to see support for Issue:connection.createArrayOf("timestamp", new Instant[] {Instant.now()} ) produces an error
Not sure if this is intentional for now or an oversight Performance Question:Before I saw that this had been implemented I passed arrays as literals from java then casting the parameter to the array type in the sql, it seems passing the array literal is many times faster than using public static void main(String[] args) throws SQLException {
var jdbcClient = JdbcClient.create(new SingleConnectionDataSource("jdbc:duckdb:", true));
jdbcClient.sql("create table foo(i int)")
.update();
String arrayLiteral = IntStream.range(0, 10000).mapToObj(String::valueOf).collect(Collectors.joining(",", "[", "]"));
System.out.println("ArrayLiteral");
for (int i = 0; i < 100; i++) {
final var now2 = Instant.now();
jdbcClient.sql("insert into foo select unnest(:arr::int[])")
.param("arr", arrayLiteral)
.update();
final var duration = Duration.between(now2, Instant.now());
System.out.println(duration.toNanos() / 1000000d);
}
jdbcClient.sql("truncate table foo")
.update();
System.out.println("`Connection#createArrayOf`");
final var elements = IntStream.range(0, 10000).boxed().toArray();
try (final var connection = new SingleConnectionDataSource("jdbc:duckdb:", true).getConnection()) {
for (int i = 0; i < 100; i++) {
final var now = Instant.now();
jdbcClient.sql("insert into foo select unnest(:arr::int[])")
.param("arr", connection.createArrayOf("int4", elements))
.update();
final var duration = Duration.between(now, Instant.now());
System.out.println(duration.toNanos() / 1000000d);
}
}
} output on M1 mac showing 1.3ms for array literal vs 6.4ms for unfortunately, I've not got the time to dig into potential performance improvements on the java side and I don't know c++ so can't help there 😓 |
No description provided.