425 |
436 |
426 (Any X, XN WHERE X is Person, X surname XN) UNION (Any X,XN WHERE X is Company, X name XN) |
437 (Any X, XN WHERE X is Person, X surname XN) UNION (Any X,XN WHERE X is Company, X name XN) |
427 |
438 |
428 |
439 |
429 .. _RQLFunctions: |
440 .. _RQLFunctions: |
|
441 |
430 Available functions |
442 Available functions |
431 ~~~~~~~~~~~~~~~~~~~ |
443 ~~~~~~~~~~~~~~~~~~~ |
432 |
444 |
433 Below is the list of aggregate and transformation functions that are supported |
445 Below is the list of aggregate and transformation functions that are supported |
434 nativly by the framework. Notice that cubes may define additional functions. |
446 nativly by the framework. Notice that cubes may define additional functions. |
435 |
447 |
436 .. _RQLAggregateFunctions: |
448 .. _RQLAggregateFunctions: |
|
449 |
437 Aggregate functions |
450 Aggregate functions |
438 ``````````````````` |
451 ``````````````````` |
439 +------------------------+----------------------------------------------------------+ |
452 +--------------------+----------------------------------------------------------+ |
440 | :function:`COUNT` | return the number of rows | |
453 | :func:`COUNT` | return the number of rows | |
441 +------------------------+----------------------------------------------------------+ |
454 +--------------------+----------------------------------------------------------+ |
442 | :function:`MIN` | return the minimum value | |
455 | :func:`MIN` | return the minimum value | |
443 +------------------------+----------------------------------------------------------+ |
456 +--------------------+----------------------------------------------------------+ |
444 | :function:`MAX` | return the maximum value | |
457 | :func:`MAX` | return the maximum value | |
445 +------------------------+----------------------------------------------------------+ |
458 +--------------------+----------------------------------------------------------+ |
446 | :function:`AVG` | return the average value | |
459 | :func:`AVG` | return the average value | |
447 +------------------------+----------------------------------------------------------+ |
460 +--------------------+----------------------------------------------------------+ |
448 | :function:`SUM` | return the sum of values | |
461 | :func:`SUM` | return the sum of values | |
449 +------------------------+----------------------------------------------------------+ |
462 +--------------------+----------------------------------------------------------+ |
450 | :function:`COMMA_JOIN` | return each value separated by a comma (for string only) | |
463 | :func:`COMMA_JOIN` | return each value separated by a comma (for string only) | |
451 +------------------------+----------------------------------------------------------+ |
464 +--------------------+----------------------------------------------------------+ |
452 |
465 |
453 All aggregate functions above take a single argument. Take care some aggregate |
466 All aggregate functions above take a single argument. Take care some aggregate |
454 functions (e.g. :keyword:`MAX`, :keyword:`MIN`) may return `None` if there is no |
467 functions (e.g. :keyword:`MAX`, :keyword:`MIN`) may return `None` if there is no |
455 result row. |
468 result row. |
456 |
469 |
457 .. _RQLStringFunctions: |
470 .. _RQLStringFunctions: |
|
471 |
458 String transformation functions |
472 String transformation functions |
459 ``````````````````````````````` |
473 ``````````````````````````````` |
460 |
474 |
461 +-----------------------------+-----------------------------------------------------------------+ |
475 +-------------------------+-----------------------------------------------------------------+ |
462 | :function:`UPPER(String)` | upper case the string | |
476 | :func:`UPPER(String)` | upper case the string | |
463 +-----------------------------+-----------------------------------------------------------------+ |
477 +-------------------------+-----------------------------------------------------------------+ |
464 | :function:`LOWER(String)` | lower case the string | |
478 | :func:`LOWER(String)` | lower case the string | |
465 +-----------------------------+-----------------------------------------------------------------+ |
479 +-------------------------+-----------------------------------------------------------------+ |
466 | :function:`LENGTH(String)` | return the length of the string | |
480 | :func:`LENGTH(String)` | return the length of the string | |
467 +-----------------------------+-----------------------------------------------------------------+ |
481 +-------------------------+-----------------------------------------------------------------+ |
468 | :function:`SUBSTRING( | extract from the string a string starting at given index and of | |
482 | :func:`SUBSTRING( | extract from the string a string starting at given index and of | |
469 | String, start, length)` | given length | |
483 | String, start, length)`| given length | |
470 +-----------------------------+-----------------------------------------------------------------+ |
484 +-------------------------+-----------------------------------------------------------------+ |
471 | :function:`LIMIT_SIZE( | if the length of the string is greater than given max size, | |
485 | :func:`LIMIT_SIZE( | if the length of the string is greater than given max size, | |
472 | String, max size)` | strip it and add ellipsis ("..."). The resulting string will | |
486 | String, max size)` | strip it and add ellipsis ("..."). The resulting string will | |
473 | | hence have max size + 3 characters | |
487 | | hence have max size + 3 characters | |
474 +-----------------------------+-----------------------------------------------------------------+ |
488 +-------------------------+-----------------------------------------------------------------+ |
475 | :function:`TEXT_LIMIT_SIZE( | similar to the above, but allow to specify the MIME type of the | |
489 | :func:`TEXT_LIMIT_SIZE( | similar to the above, but allow to specify the MIME type of the | |
476 | String, format, max size)` | text contained by the string. Supported formats are text/html, | |
490 | String, format, | text contained by the string. Supported formats are text/html, | |
477 | | text/xhtml and text/xml. All others will be considered as plain | |
491 | max size)` | text/xhtml and text/xml. All others will be considered as plain | |
478 | | text. For non plain text format, sgml tags will be first removed| |
492 | | text. For non plain text format, sgml tags will be first removed| |
479 | | before limiting the string. | |
493 | | before limiting the string. | |
480 +-----------------------------+-----------------------------------------------------------------+ |
494 +-------------------------+-----------------------------------------------------------------+ |
481 |
495 |
482 .. _RQLDateFunctions: |
496 .. _RQLDateFunctions: |
|
497 |
483 Date extraction functions |
498 Date extraction functions |
484 ````````````````````````` |
499 ````````````````````````` |
485 |
500 |
486 +------------------------------+----------------------------------------+ |
501 +--------------------------+----------------------------------------+ |
487 | :function:`YEAR(Date)` | return the year of a date or datetime | |
502 | :func:`YEAR(Date)` | return the year of a date or datetime | |
488 +------------------------------+----------------------------------------+ |
503 +--------------------------+----------------------------------------+ |
489 | :function:`MONTH(Date)` | return the year of a date or datetime | |
504 | :func:`MONTH(Date)` | return the year of a date or datetime | |
490 +------------------------------+----------------------------------------+ |
505 +--------------------------+----------------------------------------+ |
491 | :function:`DAY(Date)` | return the year of a date or datetime | |
506 | :func:`DAY(Date)` | return the year of a date or datetime | |
492 +------------------------------+----------------------------------------+ |
507 +--------------------------+----------------------------------------+ |
493 | :function:`HOUR(Datetime)` | return the year of a datetime | |
508 | :func:`HOUR(Datetime)` | return the year of a datetime | |
494 +------------------------------+----------------------------------------+ |
509 +--------------------------+----------------------------------------+ |
495 | :function:`MINUTE(Datetime)` | return the year of a datetime | |
510 | :func:`MINUTE(Datetime)` | return the year of a datetime | |
496 +------------------------------+----------------------------------------+ |
511 +--------------------------+----------------------------------------+ |
497 | :function:`SECOND(Datetime)` | return the year of a datetime | |
512 | :func:`SECOND(Datetime)` | return the year of a datetime | |
498 +------------------------------+----------------------------------------+ |
513 +--------------------------+----------------------------------------+ |
499 |
514 |
500 .. _RQLOtherFunctions: |
515 .. _RQLOtherFunctions: |
|
516 |
501 Other functions |
517 Other functions |
502 ``````````````` |
518 ``````````````` |
503 +---------------------------+--------------------------------------------------------------------+ |
519 +-----------------------+--------------------------------------------------------------------+ |
504 | :function:`ABS(num)` | return the absolute value of a number | |
520 | :func:`ABS(num)` | return the absolute value of a number | |
505 +---------------------------+--------------------------------------------------------------------+ |
521 +-----------------------+--------------------------------------------------------------------+ |
506 | :function:`RANDOM()` | return a pseudo-random value from 0.0 to 1.0 | |
522 | :func:`RANDOM()` | return a pseudo-random value from 0.0 to 1.0 | |
507 +---------------------------+--------------------------------------------------------------------+ |
523 +-----------------------+--------------------------------------------------------------------+ |
508 | :function:`FSPATH(X)` | expect X to be an attribute whose value is stored in a | |
524 | :func:`FSPATH(X)` | expect X to be an attribute whose value is stored in a | |
509 | | :ref:`BFSStorage` and return its path on the file system | |
525 | | :class:`BFSStorage` and return its path on the file system | |
510 +---------------------------+--------------------------------------------------------------------+ |
526 +-----------------------+--------------------------------------------------------------------+ |
511 | :function:`FTKIRANK(X)` | expect X to be an entity used in a has_text relation, and return a | |
527 | :func:`FTKIRANK(X)` | expect X to be an entity used in a has_text relation, and return a | |
512 | | number corresponding to the rank order of each resulting entity | |
528 | | number corresponding to the rank order of each resulting entity | |
513 +---------------------------+--------------------------------------------------------------------+ |
529 +-----------------------+--------------------------------------------------------------------+ |
514 | :function:`CAST(Type, X)` | expect X to be an attribute and return it casted into the given | |
530 | :func:`CAST(Type, X)` | expect X to be an attribute and return it casted into the given | |
515 | | final type | |
531 | | final type | |
516 +---------------------------+--------------------------------------------------------------------+ |
532 +-----------------------+--------------------------------------------------------------------+ |
517 |
533 |
518 |
534 |
519 .. _RQLExamples: |
535 .. _RQLExamples: |
|
536 |
520 Examples |
537 Examples |
521 ~~~~~~~~ |
538 ~~~~~~~~ |
522 |
539 |
523 - *Search for the object of identifier 53* |
540 - *Search for the object of identifier 53* |
524 :: |
541 :: |