header

Metadata Queries

AMGA provides its own query language which is similar to the SQL query language. It tries to offer a large subset of the common functionality of database systems in a transparent way to the user. The biggest difference to SQL is that in AMGA's query language tables are referred to as references to directories. AMGA will ensure access restrictions on the data so that users cannot infer data from queries if they have no read-access to that data.

Queries are performed in the following AMGA commands:

    Query> find entry_pattern query_condition
    Query> selectattr column_1_query ... column_n_query query_condition
    Query> updateattr attr_1 update_query_1  .... attr_n update_query_n query_condition
    Query> updateattr_single attr_1 update_query_1  .... attr_n update_query_n query_condition

A query condition is a query which returns a boolean in order to select or not select an entry for retrieval or update. Examples are

    /jobdir:events>1000 and /configdir:key=/jobdir:key
    like(/jobdir:FILE, "t%")

Query conditions are used in the WHERE statements of the SQL queries which are passed to the backends.

The other queries used in the AMGA commands return general values which are returned to the user in the selectattr command or which are used to update attributes in the updateattr command.

Queries can contain either literal values like numbers or strings which are marked by double quotes. Make sure to use single quotes around double quotes if the string contains spaces. Queries can also contain attributes which are evalued in the query by filling in the values of the attribtues for the current value. In AMGA all queries are in fact inner joins over all tables mentionned in any of the queries of command, that is the all possible combinations of all entries of all tables are made and those selected matching the query condition. Inner joins are the most common type of join. Some database systems provide no other kind.

References to attributes take the form:

  <dirctory>:<attribute>

where relative paths to the directory (which is synonyme for table or schema, here) are allowed. Examples are:

  Query> selectattr /test:t 'like(t, "Test%")'
  Query> selectattr count(/test:t) 'like(t, "Test%")'

From the above example you can see that also functions are allowed. Function names are case-sensitive and lowercase. The following functions are available:

Queries can contain the following operators: +, -, *, /, =, and, or, not, >=, <=, <> or !=

Special attribute names refer to the properties of an entry:

As of version 1.2.11, AMGA supports other table joins apart from the implicite cross join. The supported joins are left and right outer joins and the inner join. The following shows some examples

  Query> selectattr /t1:num /t1:name /t2:num /t2:value '/t1:num = 1 join_left_on(/t1:, /t2:,
  /t1:num = /t2:num) limit 1'
  Query> selectattr /t1:name /t2:value 'join_right_on(/t1:, /t2:, /t1:num = /t2:num)'

The following is a list of the supported joins and their translation into SQL:

The exact syntax of AMGA queries is describted in the annotated parser.y++ and lexer.l++ sourcecodes.


Generated on Mon Apr 16 13:59:18 2012 for AMGA by  doxygen 1.4.7