Pivotal Knowledge Base

Follow

Class Cast Exception when running Query with Index and IN SET

Environment

 Product  Version
 Pivotal GemFire  8.2.x
 OS  All Supported OS

Symptom

You may experience a class cast exception when running a query with index and IN SET clause using gfsh.

For example:

1. When creating a index on exampleRegion2.agentCode:

create index --name="exampleRegion2_agentCode" --expression="agentCode" --region=/exampleRegion2 --member=server1;

2.Run the query like the below, you will see class cast exception:

gfsh>query --query="select distinct region1.comCode,region2.agentCode,region2.agentName,region2.postCode from /exampleRegion1 region1,/exampleRegion2 region2 where region1.agentCode = region2.agentCode 
and region1.comCode in Set('00000000','00000001','00000002') and region2.agentCode='0000000X'" Result : false startCount : 0 endCount : 20 Message : com.gemstone.gemfire.cache.query.internal.CompiledIn cannot be cast to com.gemstone.gemfire.cache.query.internal.CompiledJunction NEXT_STEP_NAME : END 

Cause

This is a known issue in the OQL parse engine (GEM-1279) and it will be fixed in a future version of GemFire.

The reproducible condition: where-clause includes "in Set" usage and indexed fields.

From the example above, we can see that, it will throw a class cast exception since where-clause includes [region1.comCode in Set('00000000','00000001','00000002')]->"in Set usage" and [region2.agentCode='0000000X']->indexed field.

Resolution

A quick workaround for this issue is to break the "in Set" clause into multiple "=" clauses:

gfsh>query --query="select distinct region1.comCode,region2.agentCode,region2.agentName,region2.postCode from /exampleRegion1 region1,/exampleRegion2 region2 where region1.agentCode = region2.agentCode 
and (region1.comCode='00000000' or region1.comCode='00000001' or region1.comCode='00000002') and region2.agentCode='0000000X'"

 

Comments

Powered by Zendesk