Ask Your Question
0

SCRIPTING_04 - Script sent record to error:'com.streamsets.pipeline.stage.processor.scripting.ScriptRecord' object is unsubscriptable

asked 2018-12-06 06:03:48 -0600

Raaz gravatar image

updated 2018-12-06 11:51:35 -0600

Hi Team, I'm trying to implement a counter using state in Jython and Im getting this error please help me with this.

init script : state['record_counter'] = 0

script: try: for record in records: state['record_counter'] += 1 record.value['record_id'] = state['record_counter'] record.value['version'] = 1
output.write(record) except Exception as e: error.write(record, e.message)

Error Trace:

com.streamsets.pipeline.api.base.OnRecordErrorException: SCRIPTING_04 - Script sent record to error: 'com.streamsets.pipeline.stage.processor.scripting.ScriptRecord' object is unsubscriptable at com.streamsets.pipeline.stage.processor.scripting.AbstractScriptingProcessor$Err.write(AbstractScriptingProcessor.java:72) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:188) at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:206) at org.python.core.PyObject.__call__(PyObject.java:515) at org.python.core.PyObject.__call__(PyObject.java:519) at org.python.core.PyMethod.__call__(PyMethod.java:156) at org.python.pycode._pyx3688.f$0(<script>:11) at org.python.pycode._pyx3688.call_function(<script>) at org.python.core.PyTableCode.call(PyTableCode.java:171) at org.python.core.PyCode.call(PyCode.java:18) at org.python.core.Py.runCode(Py.java:1614) at org.python.core.__builtin__.eval(__builtin__.java:497) at org.python.core.__builtin__.eval(__builtin__.java:501) at org.python.util.PythonInterpreter.eval(PythonInterpreter.java:259) at org.python.jsr223.PyScriptEngine.eval(PyScriptEngine.java:57) at org.python.jsr223.PyScriptEngine.access$300(PyScriptEngine.java:20) at org.python.jsr223.PyScriptEngine$PyCompiledScript.eval(PyScriptEngine.java:250) at javax.script.CompiledScript.eval(CompiledScript.java:92) at com.streamsets.pipeline.stage.processor.scripting.AbstractScriptingProcessor.runScript(AbstractScriptingProcessor.java:285) at com.streamsets.pipeline.stage.processor.scripting.AbstractScriptingProcessor.runScript(AbstractScriptingProcessor.java:242) at com.streamsets.pipeline.stage.processor.scripting.AbstractScriptingProcessor.runBatch(AbstractScriptingProcessor.java:237) at com.streamsets.pipeline.stage.processor.scripting.AbstractScriptingProcessor.process(AbstractScriptingProcessor.java:214) at com.streamsets.pipeline.api.base.SingleLaneProcessor.process(SingleLaneProcessor.java:95) at com.streamsets.pipeline.api.base.configurablestage.DProcessor.process(DProcessor.java:35) at com.streamsets.datacollector.runner.StageRuntime.lambda$execute$2(StageRuntime.java:286) at com.streamsets.datacollector.runner.StageRuntime.execute(StageRuntime.java:235) at com.streamsets.datacollector.runner.StageRuntime.execute(StageRuntime.java:298) at com.streamsets.datacollector.runner.StagePipe.process(StagePipe.java:244) at com.streamsets.datacollector.runner.preview.PreviewPipelineRunner.lambda$runSourceLessBatch$0(PreviewPipelineRunner.java:341) at com.streamsets.datacollector.runner.PipeRunner.executeBatch(PipeRunner.java:136) at com.streamsets.datacollector.runner.preview.PreviewPipelineRunner.runSourceLessBatch(PreviewPipelineRunner.java:337) at com.streamsets.datacollector.runner.preview.PreviewPipelineRunner.runPollSource(PreviewPipelineRunner.java:319) at com.streamsets.datacollector.runner.preview.PreviewPipelineRunner.run(PreviewPipelineRunner.java:217) at com.streamsets.datacollector.runner.Pipeline.run(Pipeline.java:538) at com.streamsets.datacollector.runner.preview.PreviewPipeline.run(PreviewPipeline.java:51) at com.streamsets.datacollector.execution.preview.sync.SyncPreviewer.start(SyncPreviewer.java:218) at com.streamsets.datacollector.execution.preview.async.AsyncPreviewer.lambda$start$0(AsyncPreviewer.java:95) at com.streamsets.pipeline.lib ... (more)

edit retag flag offensive close merge delete

Comments

Update your question and include your Jython code in it.

iamontheinet gravatar imageiamontheinet ( 2018-12-06 07:53:29 -0600 )edit

added.. please check it

Raaz gravatar imageRaaz ( 2018-12-06 11:29:53 -0600 )edit

Initially I configured the pipeline Error records to be discarded. and I saw the stack trace is due to $Err.write. So I removed the error.write from script and replaced it with log.info. Now no errors but jython is not giving any output too.. This is cloud streamsets, I don't know where to find logs

Raaz gravatar imageRaaz ( 2018-12-06 12:25:01 -0600 )edit

Did you see my side note above? "make sure try... except is within for... records loop and not the other way around." -- The reason why it was failing before you removed "error.write" is because there's no reference to "record" *outside* of for... records loop. Does that make sense?

iamontheinet gravatar imageiamontheinet ( 2018-12-06 13:45:15 -0600 )edit

Yes I got that.. Thanks

Raaz gravatar imageRaaz ( 2018-12-06 23:30:28 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-12-06 12:18:26 -0600

iamontheinet gravatar image

updated 2018-12-06 12:19:10 -0600

It works for me in SDC 3.5.2 and 3.6.0. What version of SDC are you running? And, is this all the code you have in your Jython Eval? BTW, side note: make sure try... except is within for... records loop and not the other way around.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-12-06 06:03:48 -0600

Seen: 20 times

Last updated: Dec 06