Handling ANY (java objects) type with XPATH

In some cases your query in Smart QL will handle java objects from Jira model:

  • When using AUX.JQL function, some fields available under projection parameter are java objects from Jira, like collection of labels (Collection<Label>), affected versions (Collection<Version>), fix versions and others.
  • The same applies to AUX.GETFIELD function. You can use any field here available in AUX.JQL.

Smart QL does not convert those fields for further processing in SQL, because we would lock down the possibilities for you. It rather lets the conversion for you to feet your specific needs. In other words, Smart QL does not convert collection of labels to some fancy string like label1, label2, label3 because such value in a collumn is hard to process further. Instead of doing this Smart QL leaves the raw java object Collection<Label> and gives you tools to convert this to any information you need in your query. This could be the count of labels per issue, or boolean information whether issue is labelled with specific value. It is solely up to you.

The mentioned tool the Smart QL gives you is ability to handle java objects with XPATH expressions in AUX.PATH function directly and for your convenience in AUX.SQL and AUX.GETFIELD when declaring a field.

See XPath intro and JXPath user guide for greater details on XPATH syntaxt and semantics.

Java types

Smart QL can handle following java types:

TypeDocumentationField name (use it in AUX.JQL and AUX.GETFIELD)Notes
ApplicationUserJavadocsASSIGNEEOBJECT, CREATOROBJECT, REPORTEROBJECT
ProjectJavadocsPROJECTOBJECT
VersionJavadocsAFFECTEDVERSIONS, FIXVERSIONSMentioned fields returns collection of Versions  - Collection<Version> in Java.
ProjectComponentJavadocsCOMPONENTSField returns collection of Compoents - Collection<Version> in Java.
AttachmentJavadocsATTACHMENTSField return collection - Collection<Attachment> in Java.
LabelJavadocsLABELSField return collection - Collection<Label> in Java.
IssueTypeJavadocsISSUETYPEOBJECT

Collections

Having several fields of issue as Collection of java objects is the main reason that, Smart QL does not handle all issue fields on its own and convert it to SQL types. Flattening collection to a column/row value loses information, whether letting handling them by user with XPATH expressions gives more flexibility and power. See examples:

All issues affecting more the one version in a specific project
SELECT * 
FROM TABLE(AUX.JQL('Key, AffectedVersions PATH `count(.)` AS `AFFVERNO`', 'Project = "Sample Project"')) JQL
WHERE JQL.AFFVERNO > 1
First fix versions for selected issues
SELECT AUX.ASISSUEKEY(i.id), AUX.GETFIELD(i.id, 'FixVersions PATH `.[1]/name`') FIRST_FIX_VERSION
FROM issues i
WHERE i.votes > 0
Check if issue belongs to at leat one closed sprints
SELECT AUX.ASISSUEKEY(i.id), AUX.GETFIELD(i.id, 'Sprint PATH `boolean(state="CLOSED")`') 
FROM issues i