[
https://issues.apache.org/jira/browse/BEAM-14432?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17536622#comment-17536622
]
Vitan Remus commented on BEAM-14432:
------------------------------------
hi, JdbcWriteResult might lack information but I would like to add the argument
from the point of view of
[RowMapper|https://beam.apache.org/releases/javadoc/2.0.0/org/apache/beam/sdk/io/jdbc/JdbcIO.RowMapper.html[].
|http://example.com]./] The semantics for it's existence are clear : '{_}An
interface used by JdbcIO.Read for converting each row of the ResultSet into an
element of the resulting PCollection.{_}'
So, both JdbcIO.Read and JdbcWriteResult request a RowMapper but consume it in
a totally different manner. Even though the RowMapper does not mention
JdbcWriteResult in its description reusing it with a change of semantics is
misleading at least :) . This kind of object is something that can effectively
be reused for both cases. Any kind of logic like: testing if the resultset has
at least a record or iterating over multiple records is totally besides the
point stated in the description.
In my humble opinion the JdbcWriteResult is misusing the RowMapper object by
not calling it whenever is has a record that should be mapped into an element
(as description implies).
> JdbcIO: WriteWithResult not works as expected when maps ResultSet
> -----------------------------------------------------------------
>
> Key: BEAM-14432
> URL: https://issues.apache.org/jira/browse/BEAM-14432
> Project: Beam
> Issue Type: Improvement
> Components: io-java-jdbc
> Affects Versions: 2.34.0, 2.35.0, 2.36.0, 2.37.0, 2.38.0
> Reporter: Damian
> Priority: P2
> Attachments: SolutionProposal.png
>
>
> WriteWithResult [1] in org.apache.beam.sdk.io.jdbc.JdbcIO [2] works in
> different way than expected. Difference lies in implementation of approach to
> row mappers in WriteFn and way how processRecord method works [3]. Current
> implementation left for developer responsibility for processing returned
> result set from write operation when result can be empty, one or many.
> Instead result should be iterated when next value is available, like for
> ReadFn [4]. Issue exists since improvement:
> https://issues.apache.org/jira/browse/BEAM-11873 
> In the attachment diff with possible solution.
> [1]:
> [https://github.com/apache/beam/blob/8d3b4bbaa942d62ac16b7ca7ff8858e102497b46/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcIO.java#L1551]
>
> [2]:
> [https://github.com/apache/beam/blob/master/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcIO.java]
>
> [3]:
> [https://github.com/apache/beam/blob/8d3b4bbaa942d62ac16b7ca7ff8858e102497b46/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcIO.java#L2407-L2423]
>
> [4]:
> [https://github.com/apache/beam/blob/8d3b4bbaa942d62ac16b7ca7ff8858e102497b46/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcIO.java#L1370-L1373]
>
>
--
This message was sent by Atlassian Jira
(v8.20.7#820007)