I'm trying to read from a postgres table using Apache beam's python SDK. I have installed the Java SDK as the documentation says. I'm using the latest release. My code stands as follows:
import logging
import typing
import apache_beam as beam
from apache_beam import coders
from apache_beam.io.jdbc import ReadFromJdbc
from apache_beam.options.pipeline_options import PipelineOptions
from past.builtins import unicode
def run(argv=None):
beam_options = PipelineOptions()
ExampleRow = typing.NamedTuple('ExampleRow', [('id', int), ('name', unicode)])
coders.registry.register_coder(ExampleRow, coders.RowCoder)
with beam.Pipeline(options=beam_options) as p:
result = (
p
| 'Read from jdbc' >> ReadFromJdbc(
table_name='jdbc_external_test_read',
driver_class_name='org.postgresql.Driver',
jdbc_url='jdbc:postgresql://localhost:5432/example',
username='postgres',
password='postgres')
)
if __name__ == '__main__':
logging.getLogger(__name__).setLevel(logging.INFO)
run()
But when I run it I get the error ValueError: No logical type registered for URN 'beam:logical_type:javasdk:v1'