Skip to content

Commit

Permalink
squash - Add GenQuery information page
Browse files Browse the repository at this point in the history
  • Loading branch information
alanking committed Apr 5, 2024
1 parent 3b86dbb commit e695643
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions docs/system_overview/genquery.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

GenQuery is the SQL-like syntax used to query the iRODS catalog. It is used throughout the server to accomplish everything required of the system from resource hierarchy resolution to enforcing permissions, as well as directly by users via `iquest` and other clients.

This page describes syntax for GenQuery as it has existed in iRODS for almost as long as it has existed. A more modern solution is now available in the iRODS server called GenQuery2 which will eventually replace the legacy GenQuery implementation.
This page describes syntax for **GenQuery** because it has existed for almost as long as iRODS has existed and is used extensively throughout existing iRODS clients and servers. A more modern solution is now available in the iRODS server called **GenQuery2** which will eventually replace the legacy GenQuery implementation.

## GenQuery Syntax

### Selection syntax

The general form for selecting attributes in a query is:
```
select ATTRIBUTE [, ]*
select ATTRIBUTE[, ATTRIBUTE]*
```
...where ATTRIBUTE is a GenQuery attribute. Additional selected attributes are appended via a comma-delimited list. See [GenQuery Attributes](#genquery-attributes) for a list of attributes.

GenQuery also supports a few "aggregation operators" which return a variety of information generated from the results rather than the results themselves:
- SUM: Returns the sum of the results. The results must be summable.
- SUM: Returns the sum of the results.
- COUNT: Returns a count of the number of unique results from the selected attributes.
- MIN: Returns the minimum value from the set of results.
- MAX: Returns the maximum value from the set of results.
Expand All @@ -27,6 +27,8 @@ Results can be ordered by using one of these operators:
- ORDER: Returns the results in ascending order.
- ORDER_DESC: Returns the results in descending order.

The order operators can be applied to any selected ATTRIBUTE and the order of selected attributes does not affect the behavior. If multiple ATTRIBUTEs have an order operator applied, they are executed in order as they appear.

### Conditional syntax

Results can be selected conditionally by using the `where` clause. The general form for conditional arguments is:
Expand All @@ -50,6 +52,7 @@ OPERATOR can be one of a few different relational operators, most of which will
- 'like': ATTRIBUTE must match the wildcard expression in VALUE. See [Wildcard Expressions](#wildcard-expressions) for more information.
- 'not like': ATTRIBUTE must not match the wildcard expression in VALUE. See [Wildcard Expressions](#wildcard-expressions) for more information.
- 'between': ATTRIBUTE must be between two VALUEs, separated by a space. For example: `DATA_SIZE between '100' '1000'`
- 'in': ATTRIBUTE must exactly match at least one VALUE in a comma-delimited list of VALUEs. For example: `RESC_NAME in 'resc_a', 'resc_b'`

### Wildcard Expressions

Expand Down Expand Up @@ -273,10 +276,14 @@ Here is the complete list of GenQuery attributes available for use anywhere an A
- RESC_CREATE_TIME
- RESC_FREE_SPACE
- RESC_FREE_SPACE_TIME
- RESC_GROUP_ID
- RESC_GROUP_NAME
- RESC_GROUP_RESC_ID
- RESC_ID
- RESC_INFO
- RESC_LOC
- RESC_MODIFY_TIME
- RESC_MODIFY_TIME_MILLIS
- RESC_NAME
- RESC_PARENT
- RESC_PARENT_CONTEXT
Expand Down Expand Up @@ -372,7 +379,9 @@ Here is the complete list of GenQuery attributes available for use anywhere an A
- TICKET_WRITE_FILE_COUNT
- TICKET_WRITE_FILE_LIMIT
- TOKEN_COMMENT
- TOKEN_CREATE_TIME
- TOKEN_ID
- TOKEN_MODIFY_TIME
- TOKEN_NAME
- TOKEN_NAMESPACE
- TOKEN_VALUE
Expand Down Expand Up @@ -425,9 +434,9 @@ Find the aggregate size of the data objects in `/tempZone/home/rods` and all of
```
SELECT SUM(DATA_SIZE), RESC_NAME WHERE COLL_NAME LIKE '/tempZone/home/rods%'
```
Get a list of data object IDs in `/tempZone/home/rods` and all of its subcollections, ordered from highest ID value to lowest ID value:
Get a list of data object names and IDs in `/tempZone/home/rods` and all of its subcollections, ordered from highest ID value to lowest ID value:
```
SELECT ORDER_DESC(DATA_ID) WHERE COLL_NAME LIKE '/tempZone/home/rods%'
SELECT DATA_NAME, ORDER_DESC(DATA_ID) WHERE COLL_NAME LIKE '/tempZone/home/rods%'
```
Find all data objects with sizes between 100000 and 100200 bytes:
```
Expand Down

0 comments on commit e695643

Please sign in to comment.