[ 
https://issues.apache.org/jira/browse/PHOENIX-6683?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17518006#comment-17518006
 ] 

ASF GitHub Bot commented on PHOENIX-6683:
-----------------------------------------

chrajeshbabu commented on PR #73:
URL: 
https://github.com/apache/phoenix-connectors/pull/73#issuecomment-1090085221

   > I haven't looked into the logic closely. Do we process the parentheses 
correctly ?
   > 
   > i.e. Make sure that we do not turn
   > 
   > (a and b or c) into (a and (b or c))
   
   Yes this is not happening and AND is getting precedence. Just added another 
test case to ensure that..
   
   45336 [main] DEBUG org.apache.phoenix.execute.BaseQueryPlan  - Iterator for 
table N000001 ready: resultIterators=ResultIterators 
[name=PARALLEL,id=5337088f-cf25-3568-ad24-630b5fd8c07f,scans=[[{"loadColumnFamiliesOnDemand":true,"filter":"**((\"ENTITY_INSTANCE_ID\"
 = 40 AND \"CASE_MATCH_TYPE\" = 'M') OR NOT (\"CANCELLATION_FLAG\" = 
'Y'))"**,"startRow":"","stopRow":"","batch":-1,"cacheBlocks":true,"totalColumns":3,"maxResultSize":-1,"families":{"0":["\\x00\\x00\\x00\\x00","\\x80\\x0B","\\x80\\x0C"]},"caching":2147483647,"maxVersions":1,"timeRange":[0,9223372036854775807]}]]],
 index=0]
   




> Surround the OR filters with parentheses while converting spark filters to 
> phoenix expessions
> ---------------------------------------------------------------------------------------------
>
>                 Key: PHOENIX-6683
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-6683
>             Project: Phoenix
>          Issue Type: Bug
>          Components: spark-connector
>            Reporter: Rajeshbabu Chintaguntla
>            Assignee: Rajeshbabu Chintaguntla
>            Priority: Major
>
> If there are mix of *AND* and *OR* filters in the query while converting the 
> to phoenix filter from spark filters no parentheses got added to *OR* filters 
>  which is leading to wrong filter and finally getting wrong data.
> For example if the filter is used is below
> {code}
>  where ENTITY_INSTANCE_ID = 40 and  (CANCELLATION_FLAG <> 'Y' OR 
> CANCELLATION_FLAG IS NULL ) and CASE_MATCH_TYPE='M'
> {code}
> which is getting converted to an expression and leading to wrong result 
> because result is always giving most of the records matching 
> CANCELLATION_FLAG is not 'Y'
> {code}
> NOT  "CANCELLATION_FLAG" = 'Y' OR  "CANCELLATION_FLAG" IS NULL AND 
> "CASE_MATCH_TYPE" IS NOT NULL AND "ENTITY_INSTANCE_ID" = 40 AND 
> "ENTITY_INSTANCE_ID" IS NOT NULL AND "CASE_MATCH_TYPE" = 'M'
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to