connect icon indicating copy to clipboard operation
connect copied to clipboard

Sequence input component gives messages of type "unknown"

Open krazylek opened this issue 3 years ago • 2 comments

If I use the example provided in documentation:

input:
  sequence:
    sharded_join:
      type: full-outer
      id_path: uuid
      merge_strategy: array
    inputs:
      - csv:
          paths:
            - ./hobbies.csv
            - ./main.csv

The output result is as expected giving me the 3 messages as indicated:

{"age":"28","name":"Emma","uuid":"BBB"}
{"age":"45","hobby":"pokemon go","name":"Geri","uuid":"CCC"}
{"age":"34","hobby":["rowing","golf"],"name":"Melanie","uuid":"AAA"}

Unfortunately these messages are not usable in a pipeline, and are of type "unknown".

For example if I add this mapping:

input:
  sequence:
    sharded_join:
      type: full-outer
      id_path: uuid
      merge_strategy: array
    inputs:
      - csv:
          paths:
            - ./hobbies.csv
            - ./main.csv

pipeline:
  processors:
    - mapping: |
        root = {}
        root.original = this
        root.original_type = this.type()
        root.name_value = this.name
        root.name_type = this.name.type()

I get the following output:

{"name_type":"null","name_value":null,"original":{"age":"28","name":"Emma","uuid":"BBB"},"original_type":"unknown"}
{"name_type":"null","name_value":null,"original":{"age":"34","hobby":["rowing","golf"],"name":"Melanie","uuid":"AAA"},"original_type":"unknown"}
{"name_type":"null","name_value":null,"original":{"age":"45","hobby":"pokemon go","name":"Geri","uuid":"CCC"},"original_type":"unknown"}

Basically this is accessible, with an unknown type but none of it's properties are.

Also, any attempt to add a property to thiswill result in an error:

    - mapping: |
        root = this
        root.test = 5

Gives:

failed to assign result (line 2): unable to set target path original as the value of the root was a non-object type (unknown)

krazylek avatar Feb 27 '23 03:02 krazylek

Hey @krazylek, nice find! I proposed a tentative fix in #1776.

I was able to reproduce it on demand with the following config:

input:
  sequence:
    sharded_join:
      type: full-outer
      id_path: uuid
      merge_strategy: array
    inputs:
      - generate:
          count: 1
          interval: 0s
          mapping: |
            root = {"age":"28","name":"Emma","uuid":"BBB"}
      - generate:
          count: 1
          interval: 0s
          mapping: |
            root = {"age":"45","hobby":"pokemon go","name":"Geri","uuid":"CCC"}

  processors:
    - mapping: |
        root.original_type = this.type()

mihaitodor avatar Feb 27 '23 03:02 mihaitodor

Thank you for the prompt fix!

krazylek avatar Feb 27 '23 21:02 krazylek