Search code examples
pythonetlcdap

python transform in CDAP Tool


I have trying to create a python transformation in CDAP where I am facing below issue. Request you to kindly check and let me know the update as soon as possible.

Please find the below issue,use case for your reference.

Issue : Configuring stage python is null.

Use case: user is importing data from MYSQL and at python transform we are using sample script and exporting data to File.

Please check the attached screenshot for your reference.

  def transform(record, emitter, context):
            if (record['actor_id'] > 0):
                  tax = record['actor_id'] * 10
                   emitter.emit({
                     'actor_id': record['actor_id'],
                     'tax': tax,
                     'total': record['subtotal'] + tax,
                   })

actor_id is transformed and processed to the next stage.


Solution

  • Replace your code with

    def transform(record, emitter, context):
          if (record['actor_id'] > 0):
            tax = record['actor_id'] * 10
            emitter.emit({
               'actor_id': record['actor_id'],
               'tax': tax,
               'total': record['subtotal'] + tax,
             })
    

    removed unwanted spaces enter image description here