Skip to content

Instantly share code, notes, and snippets.

@sandboxws
Last active December 29, 2018 06:08
Show Gist options
  • Select an option

  • Save sandboxws/7a0d1dacfaf5714090f182ebc12d8921 to your computer and use it in GitHub Desktop.

Select an option

Save sandboxws/7a0d1dacfaf5714090f182ebc12d8921 to your computer and use it in GitHub Desktop.
PCollection<HashMap<String, Object>> rows = pipeline.apply(
"Read Albums from PG",
JdbcIO.<HashMap<String, Object>>read()
.withDataSourceConfiguration(JdbcIO.DataSourceConfiguration.create(pgDataSource))
.withCoder(TableRowCoder.of())
// Map ResultSet row to a HashMap
.withRowMapper(new RowMapper<HashMap<String, Object>>() {
@Override
public HashMap<String, Object> mapRow(ResultSet resultSet) throws Exception {
return TableRowMapper.asMap(resultSet, tableName, pkName);
}
})
.withQuery("select * from public.\"Album\""));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment