How to run PQL query in AEP? | Community
Skip to main content
Mario248
Level 7
August 19, 2025
Solved

How to run PQL query in AEP?

  • August 19, 2025
  • 1 reply
  • 579 views

I created a batch audience and would like to evaluate the condition to see how many profiles qualify, mainly to verify that the condition I added is correct. I used the 'Code View' option to review the PQL details. Below is the PQL for my batch audience

 

(select _Subscriptions1 from consents.marketing.email.subscriptions.values() where _Subscriptions1.val in ["y"]) and CHAIN(xEvent, timestamp, [C0: WHAT(_experience.customerJourneyManagement.messageDeliveryfeedback.feedbackStatus in ["sent"] and _experience.customerJourneyManagement.messageExecution.messageID.equals("e77ec89b-b7f0-4e40-bdd9-6e87af00c4f3", false)) WHERE(C0.exists((timestamp occurs <= 1 day before today) or (timestamp occurs today) or (timestamp occurs <= 1 day after today))), C1: WHAT(eventType.equals("web.checkout.confirmation", false)) WHERE(C1.exists((timestamp occurs <= 1 day before today) or (timestamp occurs today) or (timestamp occurs <= 1 day after today)))])

 

I simply tried to execute this Query interface and I got this error 

5:46:30 PM > Initializing connection... 5:46:32 PM > Connection successfully established in 1.963 seconds. 5:46:32 PM > Loading autocomplete for tables and columns... 5:46:34 PM > Autocomplete for tables and columns successfully loaded. 5:46:39 PM > Running query... 5:46:39 PM > Query failed in 0.296 seconds. 5:46:39 PM > ErrorCode: 42601 queryId: 04211295-3849-4241-8857-1c54dca3362e Syntax error encountered. Reason: [line 1:104: mismatched input 'in' expecting {')', 'AND', 'EXCEPT', 'FETCH', 'GROUP', 'HAVING', 'INTERSECT', 'LIMIT', 'OFFSET', 'OR', 'ORDER', 'UNION', 'MINUS'}]

 

Looks like PQL query can not be executed directly and I tried to convert PQL to SQL using chapGPT but it could not convert it properly. Can anyone tell me what is correct way handle this case?

Best answer by bjoern__koth

Hi @mario248 

To my knowledge, PQL is only supported on API side and you cannot define segments in the UI. Also, APi-created PQL segments cannot be modified in the UI either.

In other words, you will either have to use API tools like Postman or a library the AEPP Python wrapper.

1 reply

bjoern__koth
Community Advisor and Adobe Champion
bjoern__kothCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
August 20, 2025

Hi @mario248 

To my knowledge, PQL is only supported on API side and you cannot define segments in the UI. Also, APi-created PQL segments cannot be modified in the UI either.

In other words, you will either have to use API tools like Postman or a library the AEPP Python wrapper.

Cheers from Switzerland!
Mario248
Mario248Author
Level 7
August 20, 2025

Thanks for your response. my goal is to run PQL query to see how many profile is going to qualify. Can you tell me what API we should use in postman to run the PQL query ?

Michael_Soprano
Level 10
August 26, 2025

Imho if you write queries you need to use SQL not PQL. What type of audience it would be? I assume batch

https://developer.adobe.com/experience-platform-apis/references/segmentation/#operation/createAudience

 

Create an audience then wait for next segment job or use flexible audience evaluation