Error in SQL conversion when function used a like expression

Description

When performing this kind of request on geoserver:

1 https://localhost:8080/geoserver/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=database%3Astates&SRS=EPSG%3A3857&CRS=EPSG%3A3857&TILED=true&CQL_FILTER=(strToLowerCase(%22state_name%22)%20LIKE%20%27%25texa%25%27)&WIDTH=256&HEIGHT=256&BBOX=0%2C5009377.085697312%2C5009377.085697311%2C10018754.171394624

notice there is a strToLowerCase in the filter

1 strToLowerCase(%22state_name%22)%20LIKE%20%27%25texa%25%27

The're is a rendering error, with this log:
```
java.lang.RuntimeException: java.io.IOException
at org.geotools.data.store.ContentFeatureCollection.features(ContentFeatureCollection.java:165)
at org.geotools.data.store.ContentFeatureCollection.features(ContentFeatureCollection.java:52)
at org.geoserver.security.decorators.SecuredFeatureCollection.features(SecuredFeatureCollection.java:43)
at org.geoserver.security.decorators.SecuredSimpleFeatureCollection.features(SecuredSimpleFeatureCollection.java:74)
at org.geoserver.security.decorators.SecuredSimpleFeatureCollection.features(SecuredSimpleFeatureCollection.java:31)
at org.geotools.renderer.lite.StreamingRenderer.drawPlain(StreamingRenderer.java:2576)
at org.geotools.renderer.lite.StreamingRenderer.processStylers(StreamingRenderer.java:2162)
at org.geotools.renderer.lite.StreamingRenderer.paint(StreamingRenderer.java:892)
at org.geoserver.wms.map.RenderedImageMapOutputFormat.produceMap(RenderedImageMapOutputFormat.java:587)
... 129 more
Caused by: java.io.IOException
at org.geotools.jdbc.JDBCFeatureSource.getReaderInternal(JDBCFeatureSource.java:625)
at org.geotools.jdbc.JDBCFeatureStore.getReaderInternal(JDBCFeatureStore.java:217)
at org.geotools.data.store.ContentFeatureSource.getReader(ContentFeatureSource.java:609)
at org.geotools.data.store.ContentFeatureCollection.features(ContentFeatureCollection.java:163)
... 137 more
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to org.opengis.feature.type.AttributeDescriptor
at org.geotools.data.jdbc.FilterToSQL.visit(FilterToSQL.java:547)
at org.geotools.filter.LikeFilterImpl.accept(LikeFilterImpl.java:487)
at org.geotools.data.jdbc.FilterToSQL.visit(FilterToSQL.java:736)
at org.geotools.data.jdbc.FilterToSQL.visit(FilterToSQL.java:582)
at org.geotools.filter.AndImpl.accept(AndImpl.java:45)
at org.geotools.data.jdbc.FilterToSQL.encode(FilterToSQL.java:286)
at org.geotools.data.jdbc.FilterToSQL.encodeToString(FilterToSQL.java:313)
at org.geotools.jdbc.JDBCDataStore.filter(JDBCDataStore.java:3497)
at org.geotools.jdbc.JDBCDataStore.filter(JDBCDataStore.java:3487)
at org.geotools.jdbc.JDBCDataStore.selectSQL(JDBCDataStore.java:3370)
at org.geotools.jdbc.JDBCFeatureSource.getReaderInternal(JDBCFeatureSource.java:592)
... 140 more
```
This error doesn't happen without strToLowerCase

Environment

None

Status

Assignee

Unassigned

Reporter

Lorenzo Natali

Triage

None

Affects versions

21.2

Priority

Medium