# How to allow in-place upgrade of persistent query with variable underlying data

**URL:** https://forum.confluent.io/t/how-to-allow-in-place-upgrade-of-persistent-query-with-variable-underlying-data/8949
**Category:** ksqlDB
**Created:** [27 October 2023 17:54 UTC](https://forum.confluent.io/t/how-to-allow-in-place-upgrade-of-persistent-query-with-variable-underlying-data/8949 "2023-10-27T17:54:47Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![akos](https://avatars.discourse-cdn.com/v4/letter/a/ed655f/32.png) [@akos](https://forum.confluent.io/u/akos)
#### Post date: [27 October 2023 17:54 UTC](https://forum.confluent.io/t/how-to-allow-in-place-upgrade-of-persistent-query-with-variable-underlying-data/8949/1 "2023-10-27T17:54:47Z")

</div>

Is there a solution or workaround to evolving a ksql stream in-place (`CREATE OR REPLACE`) that has a json object with variable fields?  
eg: if the incoming topic has a field like:

```auto
{
  "metadata": {
    "fieldA": "string val",
    "fieldB": 123
  }
}

```

Later, we get decide that metadata can have a new field `fieldC` that is a string value.  
From what I can tell `STRUCT` is not a good fit here because it doesn’t allow in-place update where you add a new field to the struct 😞🫠

And `MAP` is not quite the best either because it requires a consistent value type (eg: `fieldB`` would end up getting emitted by our stream as a `VARCHAR`rather than an`INT`) 😞

I’ve been playing around with the various JSON scalar functions but nothing seems to allow me to emit the values in their original types, while allowing future in-place replacements

---

<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: [26 November 2023 17:55 UTC](https://forum.confluent.io/t/how-to-allow-in-place-upgrade-of-persistent-query-with-variable-underlying-data/8949/2 "2023-11-26T17:55:15Z")

</div>

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