Ask Your Question

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

Tutgirl 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( at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke( at sun.reflect.DelegatingMethodAccessorImpl.invoke( at java.lang.reflect.Method.invoke( at org.python.core.PyReflectedFunction.__call__( at org.python.core.PyReflectedFunction.__call__( at org.python.core.PyObject.__call__( at org.python.core.PyObject.__call__( at org.python.core.PyMethod.__call__( at org.python.pycode._pyx3688.f$0(<script>:11) at org.python.pycode._pyx3688.call_function(<script>) at at at org.python.core.Py.runCode( at org.python.core.__builtin__.eval( at org.python.core.__builtin__.eval( at org.python.util.PythonInterpreter.eval( at org.python.jsr223.PyScriptEngine.eval( at org.python.jsr223.PyScriptEngine.access$300( at org.python.jsr223.PyScriptEngine$PyCompiledScript.eval( at javax.script.CompiledScript.eval( at com.streamsets.pipeline.stage.processor.scripting.AbstractScriptingProcessor.runScript( at com.streamsets.pipeline.stage.processor.scripting.AbstractScriptingProcessor.runScript( at com.streamsets.pipeline.stage.processor.scripting.AbstractScriptingProcessor.runBatch( at com.streamsets.pipeline.stage.processor.scripting.AbstractScriptingProcessor.process( at com.streamsets.pipeline.api.base.SingleLaneProcessor.process( at com.streamsets.pipeline.api.base.configurablestage.DProcessor.process( at com.streamsets.datacollector.runner.StageRuntime.lambda$execute$2( at com.streamsets.datacollector.runner.StageRuntime.execute( at com.streamsets.datacollector.runner.StageRuntime.execute( at com.streamsets.datacollector.runner.StagePipe.process( at com.streamsets.datacollector.runner.preview.PreviewPipelineRunner.lambda$runSourceLessBatch$0( at com.streamsets.datacollector.runner.PipeRunner.executeBatch( at com.streamsets.datacollector.runner.preview.PreviewPipelineRunner.runSourceLessBatch( at com.streamsets.datacollector.runner.preview.PreviewPipelineRunner.runPollSource( at at at at com.streamsets.datacollector.execution.preview.sync.SyncPreviewer.start( at com.streamsets.datacollector.execution.preview.async.AsyncPreviewer.lambda$start$0( at com.streamsets.pipeline.lib ... (more)

edit retag flag offensive close merge delete


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

Tutgirl gravatar imageTutgirl ( 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 Now no errors but jython is not giving any output too.. This is cloud streamsets, I don't know where to find logs

Tutgirl gravatar imageTutgirl ( 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

Tutgirl gravatar imageTutgirl ( 2018-12-06 23:30:28 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

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


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

Seen: 473 times

Last updated: Dec 06 '18