You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "Pierre Villard (Jira)" <ji...@apache.org> on 2025/09/11 17:11:00 UTC
[jira] [Updated] (NIFI-14958) JdbcCommon should not default arrays to arrays of bytes
[ https://issues.apache.org/jira/browse/NIFI-14958?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Pierre Villard updated NIFI-14958:
----------------------------------
Status: Patch Available (was: Open)
> JdbcCommon should not default arrays to arrays of bytes
> -------------------------------------------------------
>
> Key: NIFI-14958
> URL: https://issues.apache.org/jira/browse/NIFI-14958
> Project: Apache NiFi
> Issue Type: Bug
> Reporter: Pierre Villard
> Assignee: Pierre Villard
> Priority: Major
>
> *JdbcCommon* is used in *RecordSqlWriter* which is used by *ExecuteSQLRecord* and *QueryDatabaseTableRecord* processors.
> We construct the schema based on the result set metadata retrieved via the JDBC access when executing the SQL query.
> If a column type is currently set as ARRAY type by the driver (value = 2003), we would then create a field using
>
> {code:java}
> builder.name(columnName).type().unionOf().nullBuilder().endNull().and().bytesType().endUnion().noDefault(); {code}
> This should not be the case. If we retrieve an array of string for example, we would cause an error like:
> {code:java}
> 2025-09-11 17:18:44,940 ERROR [Timer-Driven Process Thread-1] o.a.n.p.standard.ExecuteSQLRecord ExecuteSQLRecord[id=3832c36d-0199-1000-3439-4bd0a61bef96] Unable to execute
> SQL select query [SELECT ['test'] as test;]. No FlowFile to route to failure
> org.apache.nifi.processor.exception.ProcessException: java.io.IOException: java.lang.NumberFormatException: For input string: "test"
> at org.apache.nifi.processors.standard.AbstractExecuteSQL.lambda$onTrigger$4(AbstractExecuteSQL.java:359)
> at org.apache.nifi.controller.repository.StandardProcessSession.write(StandardProcessSession.java:3107)
> at org.apache.nifi.processors.standard.AbstractExecuteSQL.onTrigger(AbstractExecuteSQL.java:355)
> at org.apache.nifi.processor.AbstractProcessor.onTrigger(AbstractProcessor.java:27)
> at org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1274)
> at org.apache.nifi.controller.tasks.ConnectableTask.invoke(ConnectableTask.java:220)
> at org.apache.nifi.controller.scheduling.AbstractTimeBasedSchedulingAgent.lambda$doScheduleOnce$0(AbstractTimeBasedSchedulingAgent.java:59)
> at org.apache.nifi.engine.FlowEngine.lambda$wrap$1(FlowEngine.java:105)
> at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
> at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
> at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
> at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
> at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
> at java.base/java.lang.Thread.run(Thread.java:1583)
> Caused by: java.io.IOException: java.lang.NumberFormatException: For input string: "test"
> at org.apache.nifi.processors.standard.sql.RecordSqlWriter.writeResultSet(RecordSqlWriter.java:88)
> at org.apache.nifi.processors.standard.AbstractExecuteSQL.lambda$onTrigger$4(AbstractExecuteSQL.java:357)
> ... 13 common frames omitted
> Caused by: java.lang.NumberFormatException: For input string: "test"
> at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
> at java.base/java.lang.Integer.parseInt(Integer.java:662)
> at java.base/java.lang.Byte.parseByte(Byte.java:195)
> at java.base/java.lang.Byte.parseByte(Byte.java:221)
> at org.apache.nifi.serialization.record.util.DataTypeUtils.toByte(DataTypeUtils.java:1514)
> at org.apache.nifi.serialization.record.util.DataTypeUtils.convertType(DataTypeUtils.java:197)
> at org.apache.nifi.serialization.record.util.DataTypeUtils.convertType(DataTypeUtils.java:174)
> at org.apache.nifi.json.WriteJsonResult.writeValue(WriteJsonResult.java:349)
> at org.apache.nifi.json.WriteJsonResult.writeArray(WriteJsonResult.java:470)
> at org.apache.nifi.json.WriteJsonResult.writeValue(WriteJsonResult.java:459)
> at org.apache.nifi.json.WriteJsonResult.writeRecord(WriteJsonResult.java:233)
> at org.apache.nifi.json.WriteJsonResult.writeRecord(WriteJsonResult.java:157)
> at org.apache.nifi.serialization.AbstractRecordSetWriter.write(AbstractRecordSetWriter.java:59)
> at org.apache.nifi.serialization.AbstractRecordSetWriter.write(AbstractRecordSetWriter.java:52)
> at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
> at java.base/java.lang.reflect.Method.invoke(Method.java:580)
> at org.apache.nifi.controller.service.StandardControllerServiceInvocationHandler.invoke(StandardControllerServiceInvocationHandler.java:251)
> at
> org.apache.nifi.controller.service.StandardControllerServiceInvocationHandler$ProxiedReturnObjectInvocationHandler.invoke(StandardControllerServiceInvocationHandler.java:237)
> at jdk.proxy26/jdk.proxy26.$Proxy192.write(Unknown Source)
> at org.apache.nifi.processors.standard.sql.RecordSqlWriter.writeResultSet(RecordSqlWriter.java:82)
> ... 14 common frames omitted {code}
> We should try to use the result set to infer the type of the elements of the array and, if not possible, default to string.
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)