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

**URL:** https://forum.confluent.io/t/error-when-using-to-query-struct-in-pull-query/11064
**Category:** ksqlDB
**Created:** [15 July 2024 03:54 UTC](https://forum.confluent.io/t/error-when-using-to-query-struct-in-pull-query/11064 "2024-07-15T03:54:08Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![nhutan](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/nhutan/32/3435_2.png) [@nhutan](https://forum.confluent.io/u/nhutan)
#### Post date: [15 July 2024 03:54 UTC](https://forum.confluent.io/t/error-when-using-to-query-struct-in-pull-query/11064/1 "2024-07-15T03:54:08Z")

</div>

“@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.

---

<div class="post-metadata">

### Author: ![dtroiano](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/dtroiano/32/1961_2.png) [@dtroiano](https://forum.confluent.io/u/dtroiano)
#### Post date: [15 July 2024 15:04 UTC](https://forum.confluent.io/t/error-when-using-to-query-struct-in-pull-query/11064/2 "2024-07-15T15:04:15Z")

</div>

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:

```noformat
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:

```noformat
SELECT my_struct->* FROM s EMIT CHANGES;

```

```noformat
SELECT my_struct->* FROM s WHERE k='the_key';

```

---

<div class="post-metadata">

### Author: ![nhutan](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/nhutan/32/3435_2.png) [@nhutan](https://forum.confluent.io/u/nhutan)
#### Post date: [16 July 2024 03:43 UTC](https://forum.confluent.io/t/error-when-using-to-query-struct-in-pull-query/11064/3 "2024-07-16T03:43:22Z")

</div>

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:

```auto
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

 ![image](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/2X/5/5f93d2b126ddc676e975d45b858ba034e865f6a2.png)

Pull queries will return the error

 ![image](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/2X/1/1a19364bfd6d4f6838aefaf0328991a5322dfe1e.png)

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

---

<div class="post-metadata">

### Author: ![dtroiano](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/dtroiano/32/1961_2.png) [@dtroiano](https://forum.confluent.io/u/dtroiano)
#### Post date: [18 July 2024 14:01 UTC](https://forum.confluent.io/t/error-when-using-to-query-struct-in-pull-query/11064/4 "2024-07-18T14:01:47Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/c49438c90c9df282e9996fdf6971be890c71b65a.svg) [@system](https://forum.confluent.io/u/system)
#### Post date: [14 August 2024 03:54 UTC](https://forum.confluent.io/t/error-when-using-to-query-struct-in-pull-query/11064/5 "2024-08-14T03:54:10Z")

</div>

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