davsclaus opened a new pull request, #28919: URL: https://github.com/apache/camel/pull/28919
Fixes [CAMEL-26149](https://issues.apache.org/jira/browse/CAMEL-26149). ### 1. The `query` option replaces a non-empty body **What was wrong:** the option was described as "Static SQL for query when the message body is empty", but `DuckDbProducer.resolveSql` takes the `CamelDuckDbQuery` header, then the `query` option, and the body only when both are empty. **What changed:** the description, not the behaviour. The option now reads "Static SQL for the execute and query operations. When set, it is used instead of the message body; the CamelDuckDbQuery header takes precedence over it." The header description and the component doc say the same. **Why not the other way round:** a route with a static `query` often gets its body from outside (HTTP, JMS, files). Letting a non-empty body replace the configured SQL would turn that body into SQL, so the documentation was fixed instead. ### 2. A SELECT with `execute`, or DDL with `query`, failed without a hint **What was wrong:** `doExecute` used `executeUpdate` and `doQuery` used `executeQuery`, so the wrong statement kind failed with the plain driver message (`executeUpdate() can only be used with queries that return nothing ...`), which does not mention the Camel operation. **What changed:** both operations now run `Statement.execute(sql)` and check whether it returned rows. A mismatch fails with a `DuckDbException` that names the operation to use (`Use operation=query for a statement that returns rows.` / `Use operation=execute for DDL or DML that returns no rows.`). The update count comes from `getUpdateCount()`, which gives the same values as `executeUpdate` with the DuckDB driver (checked: -1 for DDL, the row count for DML and for several statements in one body). The DuckDB driver also runs the statement before it rejects it in `executeUpdate`/`executeQuery`, so side effects are as before; the message and the doc say that the statement has run. The error for that case is now a `DuckDbException` without a `SQLException` cause. Other SQL errors (syntax and so on) still surface as the driver's `SQLException`. ### 3. COPY rejects a `Path` and a `byte[]` body **What was wrong:** `resolveFilePath` accepted only a `File`, a `WrappedFile` or a non-empty `String`. **What changed:** a `java.nio.file.Path` is used as its absolute path, and any other body is converted to a `String` with the type converter (`byte[]`, a stream, ...). The `@BodyTypes` of copy now list `bytes` too (`file` already covers a `Path`). The body still only carries the path, as a String body did before. ### Tests New tests in `DuckDbProducerTest` (embedded DuckDB, no external service): `copyFromPathBody`, `copyFromBytesBody`, `copyWithoutPathFails`, `executeWithSelectHintsAtQueryOperation`, `queryWithDdlHintsAtExecuteOperation` (these 5 fail without the fix), plus `queryOptionTakesPrecedenceOverBody` and `executeReturnsUpdateCount` that pin the documented precedence and the update count. `mvn clean install -Psourcecheck` in the module: 25 tests and 3 ITs pass. ### Generated files and docs Regenerated `duckdb.json` (component and catalog), the catalog copy of `duckdb-component.adoc`, and `DuckDbEndpointBuilderFactory` in `camel-endpointdsl`. The component doc explains the SQL precedence, the operation hint and the copy bodies. No upgrade-guide entry: no default or option changed; only the error of a misused operation is now a `DuckDbException`. _Claude Code on behalf of Claus Ibsen (davsclaus)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
