# OptimizedDataSet cannot be cast to BasicDataset?

**URL:** <https://forum.inductiveautomation.com/t/optimizeddataset-cannot-be-cast-to-basicdataset/26206>\
**Category:** Module Development\
**Tags:** ignition79\
**Created:** [July 1, 2019, 4:37pm UTC](https://forum.inductiveautomation.com/t/optimizeddataset-cannot-be-cast-to-basicdataset/26206 "2019-07-01T16:37:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [July 1, 2019, 4:37pm UTC](https://forum.inductiveautomation.com/t/optimizeddataset-cannot-be-cast-to-basicdataset/26206/1 "2019-07-01T16:37:15Z")

</div>

I have a client scope script function which invoke with RPC a gateway calculation which return a BasicDataset.

It was working fine in 7.9.10. Now I have the following error :

```auto
java.lang.ClassCastException: com.inductiveautomation.ignition.client.gateway_interface.OptimizedDataSet cannot be cast to com.inductiveautomation.ignition.common.BasicDataset

```

I’ve upgraded to 7.9.11.  
The dataset has about 50000 rows.  
the error seems to be caused by the size of the serialized dataset ?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 1, 2019, 4:48pm UTC](https://forum.inductiveautomation.com/t/optimizeddataset-cannot-be-cast-to-basicdataset/26206/2 "2019-07-01T16:48:17Z")

</div>

`OptimizedDataset` doesn’t inherit from `BasicDataset`. Use the alternate constructor for `BasicDataset` that just accepts any other `Dataset` implementor if you specifically need a `BasicDataset`.

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [July 1, 2019, 5:00pm UTC](https://forum.inductiveautomation.com/t/optimizeddataset-cannot-be-cast-to-basicdataset/26206/3 "2019-07-01T17:00:45Z")

</div>

(I confirm with 5000 rows, I don’t have the problem).

Thanks a lot @paul-griffith, I change the RPC return from BasicDataset to Dataset and the problem is solved 👍

---

<div class="post-metadata">

**Author:** ![brandon1](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@brandon1](https://forum.inductiveautomation.com/u/brandon1)\
**Post date:** [August 7, 2019, 8:10pm UTC](https://forum.inductiveautomation.com/t/optimizeddataset-cannot-be-cast-to-basicdataset/26206/4 "2019-08-07T20:10:07Z")

</div>

I am having the same issue but don’t exactly follow what I need to change to fix this. When I tried to change what was returned to a Dataset, it would not accept that because Dataset is just an interface. @mazeyrat can you please go into a little more detail about what you changed? Thanks.
