codelipenghui opened a new issue #4851: [pulsar-function] window function can 
not work with avro schema
URL: https://github.com/apache/pulsar/issues/4851
 
 
   **Describe the bug**
   
   Pulsar window function can not work well with avro schema
   If use Collection<IN> as input will cause following exception:
   ```
   componentType: FUNCTION
   , maxBufferedTuples=1024, functionAuthenticationSpec=null, port=34471, 
clusterName=local)
   13:40:29.125 [main] INFO  org.apache.pulsar.functions.LocalRunner - 
RuntimeSpawner quit because of
   org.apache.avro.AvroRuntimeException: 
avro.shaded.com.google.common.util.concurrent.UncheckedExecutionException: 
org.apache.avro.AvroRuntimeException: Can't find element type of Collection
    at org.apache.avro.specific.SpecificData.getSchema(SpecificData.java:227) 
~[org.apache.avro-avro-1.8.2.jar:1.8.2]
    at 
org.apache.pulsar.client.impl.schema.StructSchema.createAvroSchema(StructSchema.java:111)
 ~[org.apache.pulsar-pulsar-client-original-2.5.0-SNAPSHOT.jar:2.5.0-SNAPSHOT]
    at 
org.apache.pulsar.client.impl.schema.StructSchema.parseSchemaInfo(StructSchema.java:124)
 ~[org.apache.pulsar-pulsar-client-original-2.5.0-SNAPSHOT.jar:2.5.0-SNAPSHOT]
    at org.apache.pulsar.client.impl.schema.JSONSchema.of(JSONSchema.java:90) 
~[org.apache.pulsar-pulsar-client-original-2.5.0-SNAPSHOT.jar:2.5.0-SNAPSHOT]
    at 
org.apache.pulsar.functions.source.TopicSchema.newSchemaInstance(TopicSchema.java:143)
 
~[org.apache.pulsar-pulsar-functions-instance-2.5.0-SNAPSHOT.jar:2.5.0-SNAPSHOT]
    at 
org.apache.pulsar.functions.source.TopicSchema.newSchemaInstance(TopicSchema.java:185)
 
~[org.apache.pulsar-pulsar-functions-instance-2.5.0-SNAPSHOT.jar:2.5.0-SNAPSHOT]
    at 
org.apache.pulsar.functions.source.TopicSchema.lambda$getSchema$0(TopicSchema.java:66)
 
~[org.apache.pulsar-pulsar-functions-instance-2.5.0-SNAPSHOT.jar:2.5.0-SNAPSHOT]
    at java.util.HashMap.computeIfAbsent(HashMap.java:1126) ~[?:1.8.0_111]
    at 
org.apache.pulsar.functions.source.TopicSchema.getSchema(TopicSchema.java:66) 
~[org.apache.pulsar-pulsar-functions-instance-2.5.0-SNAPSHOT.jar:2.5.0-SNAPSHOT]
    at 
org.apache.pulsar.functions.sink.PulsarSink.initializeSchema(PulsarSink.java:327)
 
~[org.apache.pulsar-pulsar-functions-instance-2.5.0-SNAPSHOT.jar:2.5.0-SNAPSHOT]
    at org.apache.pulsar.functions.sink.PulsarSink.open(PulsarSink.java:255) 
~[org.apache.pulsar-pulsar-functions-instance-2.5.0-SNAPSHOT.jar:2.5.0-SNAPSHOT]
    at 
org.apache.pulsar.functions.instance.JavaInstanceRunnable.setupOutput(JavaInstanceRunnable.java:773)
 
~[org.apache.pulsar-pulsar-functions-instance-2.5.0-SNAPSHOT.jar:2.5.0-SNAPSHOT]
    at 
org.apache.pulsar.functions.instance.JavaInstanceRunnable.setupJavaInstance(JavaInstanceRunnable.java:203)
 
~[org.apache.pulsar-pulsar-functions-instance-2.5.0-SNAPSHOT.jar:2.5.0-SNAPSHOT]
    at 
org.apache.pulsar.functions.instance.JavaInstanceRunnable.run(JavaInstanceRunnable.java:234)
 
~[org.apache.pulsar-pulsar-functions-instance-2.5.0-SNAPSHOT.jar:2.5.0-SNAPSHOT]
    at java.lang.Thread.run(Thread.java:745) ~[?:1.8.0_111]
   Caused by: 
avro.shaded.com.google.common.util.concurrent.UncheckedExecutionException: 
org.apache.avro.AvroRuntimeException: Can't find element type of Collection
    at 
avro.shaded.com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2234)
 ~[org.apache.avro-avro-1.8.2.jar:1.8.2]
    at avro.shaded.com.google.common.cache.LocalCache.get(LocalCache.java:3965) 
~[org.apache.avro-avro-1.8.2.jar:1.8.2]
    at 
avro.shaded.com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3969) 
~[org.apache.avro-avro-1.8.2.jar:1.8.2]
    at 
avro.shaded.com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4829)
 ~[org.apache.avro-avro-1.8.2.jar:1.8.2]
    at org.apache.avro.specific.SpecificData.getSchema(SpecificData.java:225) 
~[org.apache.avro-avro-1.8.2.jar:1.8.2]
    ... 14 more
   ```
   If use ArrayList<IN> as input will cause following exception:
   ```
   Exception in thread "main" java.lang.IllegalArgumentException: Window 
function must take a collection as input
    at 
org.apache.pulsar.functions.utils.FunctionCommon.getFunctionTypes(FunctionCommon.java:104)
    at 
org.apache.pulsar.functions.utils.FunctionCommon.getFunctionTypes(FunctionCommon.java:92)
    at 
org.apache.pulsar.functions.utils.FunctionConfigUtils.doJavaChecks(FunctionConfigUtils.java:374)
    at 
org.apache.pulsar.functions.utils.FunctionConfigUtils.validate(FunctionConfigUtils.java:630)
    at org.apache.pulsar.functions.LocalRunner.start(LocalRunner.java:221)
    at org.apache.pulsar.functions.LocalRunner.main(LocalRunner.java:151)
   14:01:37.509 [Thread-1] INFO  org.apache.pulsar.functions.LocalRunner - 
Shutting down the localrun runtimeSpawner .
   ```
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to