Error when using ->* to query struct in pull query

@type”:“statement_error”,
“error_code”:40001,
“message”:“Cannot cast io.confluent.ksql.parser.tree.StructAll to io.confluent.ksql.parser.tree.SingleColumn”

I got the above error when trying to run a pull query that involves exploding a struct. The same command when run as a push query instead has no issue. I look at the ksqldb docs but it makes no mention that the ->* is valid for push queries only.

I’m trying a basic repro below and both push and pull are working. Could you provide your repro? Also try the repro below and make sure it works for you.

Given this setup:

CREATE STREAM s (
    k VARCHAR KEY,
    my_struct STRUCT<
        inner_string VARCHAR,
        inner_int INT
    >
) WITH (
    kafka_topic = 's-topic',
    partitions = 1,
    value_format = 'JSON'
);

INSERT INTO s (
    k, my_struct
) VALUES (
    'the_key', STRUCT(inner_string := 'foo', inner_int := 123)
);

Both of these queries succeed:

SELECT my_struct->* FROM s EMIT CHANGES;
SELECT my_struct->* FROM s WHERE k='the_key';

Thank you for the swift reply. I tried your repro and it works for both push and pull query. So it seems it works for Stream. However, when I tried the same but for Table instead of Stream, this is when I got the error.

The steps to reproduce the error is as follows, and I am running Confluent 7.5.2:

CREATE TABLE STRUCT_TEST_TABLE (
  k VARCHAR PRIMARY KEY,
  simple_struct SRUCT<
    inner_string VARCHAR,
    inner_int INT
  >
) with (
  kafka_topic='STRUCT_TEST_TABLE_TOPIC', 
  PARTITIONS=1, 
  VALUE_FORMAT='AVRO'
);

INSERT INTO STRUCT_TEST_TABLE (
    k, simple_struct
) VALUES (
    'the_key', STRUCT(inner_string := 'foo', inner_int := 123)
);

Push queries run with no problem

Pull queries will return the error

This same error also applies when issuing pull queries to explode struct on derived tables.

Thank you for the repro - I see the same behavior. I reported this to the ksqlDB team at Confluent.

Are you able to work around by selecting struct fields explicitly, or is the ->* syntax functionally necessary?

This topic was automatically closed after 30 days. New replies are no longer allowed.