Polber commented on code in PR #33124:
URL: https://github.com/apache/beam/pull/33124#discussion_r1861159580
##########
sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcReadSchemaTransformProvider.java:
##########
@@ -49,33 +50,174 @@ public class JdbcReadSchemaTransformProvider
extends TypedSchemaTransformProvider<
JdbcReadSchemaTransformProvider.JdbcReadSchemaTransformConfiguration> {
+ @Override
+ public @UnknownKeyFor @NonNull @Initialized String identifier() {
+ return "beam:schematransform:org.apache.beam:jdbc_read:v1";
+ }
+
+ @Override
+ public String description() {
+ return baseDescription("JDBC")
+ + "\n"
+ + "This transform can be used to read from a JDBC source using either
a given JDBC driver jar "
+ + "and class name, or by using one of the default packaged drivers
given a `jdbc_type`.\n"
+ + "\n"
+ + "#### Using a default driver\n"
+ + "\n"
+ + "This transform comes packaged with drivers for several popular JDBC
distributions. The following "
+ + "distributions can be declared as the `jdbc_type`: "
+ + JDBC_DRIVER_MAP.keySet().toString().replaceAll("[\\[\\]]", "")
+ + ".\n"
+ + "\n"
+ + "For example, reading a MySQL source using a SQL query: ::"
+ + "\n"
+ + " - type: ReadFromJdbc\n"
+ + " config:\n"
+ + " jdbc_type: mysql\n"
+ + " url: \"jdbc:mysql://my-host:3306/database\"\n"
+ + " query: \"SELECT * FROM table\"\n"
+ + "\n"
+ + "\n"
+ + "**Note**: See the following transforms which are built on top of
this transform and simplify "
+ + "this logic for several popular JDBC distributions:\n\n"
+ + " - ReadFromMySql\n"
+ + " - ReadFromPostgres\n"
+ + " - ReadFromOracle\n"
+ + " - ReadFromSqlServer\n"
+ + "\n"
+ + "#### Declaring custom JDBC drivers\n"
+ + "\n"
+ + "If reading from a JDBC source not listed above, or if it is
necessary to use a custom driver not "
+ + "packaged with Beam, one must define a JDBC driver and class name.\n"
+ + "\n"
+ + "For example, reading a MySQL source table: ::"
+ + "\n"
+ + " - type: ReadFromJdbc\n"
+ + " config:\n"
+ + " driver_jars: \"path/to/some/jdbc.jar\"\n"
+ + " driver_class_name: \"com.mysql.jdbc.Driver\"\n"
+ + " url: \"jdbc:mysql://my-host:3306/database\"\n"
+ + " table: \"my-table\"\n"
+ + "\n"
+ + "#### Connection Properties\n"
+ + "\n"
+ + "Connection properties are properties sent to the Driver used to
connect to the JDBC source. For example, "
+ + "to set the character encoding to UTF-8, one could write: ::\n"
+ + "\n"
+ + " - type: ReadFromJdbc\n"
+ + " config:\n"
+ + " connectionProperties: \"characterEncoding=UTF-8;\"\n"
+ + " ...\n"
+ + "All properties should be semi-colon-delimited (e.g.
\"key1=value1;key2=value2;\")\n";
+ }
+
+ protected String baseDescription(String jdbcType) {
+ return String.format(
+ "Read from a %s source using a SQL query or by directly accessing " +
"a single table.\n",
+ jdbcType);
+ }
+
+ protected String inheritedDescription(
Review Comment:
Refactored
--
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]