ibzib commented on pull request #15373:
URL: https://github.com/apache/beam/pull/15373#issuecomment-912820487


   @apilloud Escaping strings is difficult, since JDBC has to work with various 
[incompatible SQL 
implementations](https://stackoverflow.com/a/10574031/4400443). The answers to 
[this Stack Overflow 
question](https://stackoverflow.com/questions/2038169/how-to-quote-escape-identifiers-such-as-column-names-with-jdbc/64863308)
 suggest that we can learn the database's quoting syntax via the JDBC 
Connection. The good news is that we can access the Connection through the 
PreparedStatement in JdbcIO's 
[StatementPreparator](https://github.com/apache/beam/blob/c4e0b4ac0777f37f5eb775a8a83c56f66b3baac3/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcIO.java#L545-L552).
 The bad news is there's no way to change the query, aside from setting 
parameters, which cannot be used for column and table names.
   
   
https://github.com/apache/beam/blob/c4e0b4ac0777f37f5eb775a8a83c56f66b3baac3/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcIO.java#L1168-L1173
   
   So to get this to work I think we would have to add a method to JdbcIO that 
takes a functional interface that takes a Connection and returns a fresh 
PreparedStatement.


-- 
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]


Reply via email to