j1cs commented on issue #26003:
URL: https://github.com/apache/beam/issues/26003#issuecomment-1489380233

   I created a 
[branch](https://github.com/j1cs/coder-error-beam/tree/feat/read-rows) and gave 
me:
   ```text
   java.lang.IllegalStateException: Unable to return a default Coder for next 
step/Map/ParMultiDo(Anonymous).output [PCollection@801996095]. Correct one of 
the following root causes:
     No Coder has been manually specified;  you may do so using .setCoder().
     Inferring a Coder from the CoderRegistry failed: Unable to provide a Coder 
for java.lang.Object.
     Building a Coder using a registered CoderProvider failed.
     See suppressed exceptions for detailed failures.
     Using the default output Coder from the producing PTransform failed: 
PTransform.getOutputCoder called.
           at 
org.apache.beam.sdk.util.Preconditions.checkStateNotNull(Preconditions.java:471)
           at 
org.apache.beam.sdk.values.PCollection.getCoder(PCollection.java:284)
           at 
org.apache.beam.sdk.values.PCollection.finishSpecifying(PCollection.java:115)
           at 
org.apache.beam.sdk.runners.TransformHierarchy.finishSpecifying(TransformHierarchy.java:226)
           at 
org.apache.beam.sdk.runners.TransformHierarchy.visit(TransformHierarchy.java:212)
           at 
org.apache.beam.sdk.Pipeline.traverseTopologically(Pipeline.java:469)
           at org.apache.beam.sdk.Pipeline.validate(Pipeline.java:598)
           at org.apache.beam.sdk.Pipeline.run(Pipeline.java:322)
           at org.apache.beam.sdk.Pipeline.run(Pipeline.java:309)
           at me.jics.AppCommand.run(AppCommand.java:48)
           at picocli.CommandLine.executeUserObject(CommandLine.java:1939)
           at picocli.CommandLine.access$1300(CommandLine.java:145)
           at 
picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2358)
           at picocli.CommandLine$RunLast.handle(CommandLine.java:2352)
           at picocli.CommandLine$RunLast.handle(CommandLine.java:2314)
           at 
picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179)
           at picocli.CommandLine$RunLast.execute(CommandLine.java:2316)
           at picocli.CommandLine.execute(CommandLine.java:2078)
           at 
io.micronaut.configuration.picocli.PicocliRunner.execute(PicocliRunner.java:202)
           at 
io.micronaut.configuration.picocli.PicocliRunner.execute(PicocliRunner.java:179)
           at me.jics.AppCommand.main(AppCommand.java:23)
   
   ```
   My code:
   ```java
   public class AppCommand implements Runnable {
   
       public static void main(String[] args) throws Exception {
           int code = PicocliRunner.execute(AppCommand.class, args);
           System.exit(code);
       }
   
       public void run() {
           AppOptions options = PipelineOptionsFactory
                   .fromArgs("--runner=DirectRunner")
                   .as(AppOptions.class);
           Pipeline p = Pipeline.create(options);
           p.apply("Selecting", JdbcIO.readRows()
                   
.withDataSourceConfiguration(JdbcIO.DataSourceConfiguration.create(
                                   "org.postgresql.Driver",
                                   "jdbc:postgresql://localhost:5432/main")
                           .withUsername("myuser")
                           .withPassword("mypassword"))
                           .withQuery("select first_name, last_name from person 
where first_name = 'john'")
                   .withOutputParallelization(false)
           )
                   .apply("next step", MapElements.via(new SimpleFunction<Row, 
Object>() {
                       @Override
                       public Object apply(Row input) {
                           return super.apply(input);
                       }
                   }));
   
           p.run();
       }
   }
   ```
   


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