apache / apache/beam

JdbcIO should make the 'COMMENT' metadata available as Description

Open
#20,671 0 comments 0 reactions 0 assignees View on GitHub
improvement io java jdbc P3
Dominant language
Java
Stars
8.7k
Forks
4.7k
Avg merge
1d 20h
Merged PRs (30d)
196

Description

Currently, creating a PCollection using JdbcIO.readRows() does not make available:

 - a column's COMMENT or REMARKS metadata as the corresponding Beam field Description

 - a table COMMENT or REMARKS metadata as an appropriately named Beam schema Option

 

Making this metadata available would strongly benefit IDEs providing in-line help to create Beam pipelines, as well as semi-automated data labelling tools using metadata to infer data properties.

 

Sketch of the proposed changes in JdbcIO: 
```

@FunctionalInterface
interface BeamFieldConverter extends Serializable {
Schema.Field create(int
index, ResultSetMetaData md, DatabaseMetaData dmd) throws SQLException;
}
private static String getComment(int
index, ResultSetMetaData md, DatabaseMetaData dmd) throws SQLException {
String comment = null;

if(dmd instanceof DatabaseMetaDataUsingInfoSchema) {
ResultSet rs = dmd.getColumns(md.getCatalogName(index),
md.getSchemaName(index), md.getTableName(index), md.getColumnName(index));
if(rs.next()

&& md.getTableName(index).equals(rs.getString("TABLE_NAME"))
&& md.getColumnName(index).equals(rs.getString("COLUMN_NAME"))

) {
comment = rs.getString("REMARKS");
}
}
return comment;
}

```

 

Imported from Jira [BEAM-10946](https://issues.apache.org/jira/browse/BEAM-10946). Original Jira may contain additional context.
Reported by: ylandrin.

Contributor guide

Open the contributing guide

Research direction

Start at JdbcIO.readRows and inspect how ResultSetMetaData is converted into Beam schema fields. Use the proposed DatabaseMetaDataUsingInfoSchema/getColumns path to expose column REMARKS as Schema.Field descriptions and table remarks as a schema option. Done means both metadata forms are available to consumers such as IDEs and data-labelling tools.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.