Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UDF EXTRACTJSONFIELD does not work in combination of TRANSFORM #8122

Closed
stefanfrehse opened this issue Sep 13, 2021 · 1 comment
Closed

UDF EXTRACTJSONFIELD does not work in combination of TRANSFORM #8122

stefanfrehse opened this issue Sep 13, 2021 · 1 comment
Assignees
Labels
bug streaming-engine Tickets owned by the ksqlDB Streaming Team
Milestone

Comments

@stefanfrehse
Copy link
Contributor

stefanfrehse commented Sep 13, 2021

Describe the bug
Using the UDF EXTRACTJSONFIELD does not correctly parse JSON within a TRANSFORM lambda call while taking the path variable from the TRANSFORM argument.

To Reproduce
Steps to reproduce the behavior, include:

  • ksqlDb: 0.20.0 probably earlier as well
  • Apply the following statements demonstrates the faulty behavior:
set 'auto.offset.reset'='earliest';
CREATE STREAM STREAM_A  (
    "key" VARCHAR KEY,
    "value" VARCHAR,
    "extractor" ARRAY<VARCHAR>
) WITH(KAFKA_TOPIC = 'test-topic-transform', VALUE_FORMAT = 'JSON', PARTITIONS = 1, REPLICAS = 3);

INSERT INTO STREAM_A ("key", "value", "extractor") VALUES( 'key_1', '{\"sensor_1\": 10, \"sensor_2\": 15}', ARRAY['.sensor_1', '.sensor_2']);
INSERT INTO STREAM_A ("key", "value", "extractor") VALUES( 'key_2', '{\"sensor_1\": 3, \"sensor_2\": 11}', ARRAY['.sensor_1', '.sensor_2']);

SELECT
    "key",
    "value",
    "extractor",
    TRANSFORM("extractor", (data) => EXTRACTJSONFIELD("value", ('$' + data))) AS "unpackedValue"
    FROM STREAM_A
EMIT CHANGES;

which results currently in [10,10], and, [3,3]

Expected behavior
The result of the query should be: [10,15], and, [3,11].

@spena
Copy link
Member

spena commented Sep 21, 2021

Issue fixed here - #8123

@spena spena closed this as completed Sep 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug streaming-engine Tickets owned by the ksqlDB Streaming Team
Projects
None yet
Development

No branches or pull requests

4 participants