Skip to content

Commit

Permalink
#69: described select, added a list of supported functions
Browse files Browse the repository at this point in the history
  • Loading branch information
AnastasiiaSergienko committed May 14, 2020
1 parent 15e9c55 commit adffe93
Show file tree
Hide file tree
Showing 3 changed files with 285 additions and 10 deletions.
256 changes: 256 additions & 0 deletions doc/user_guide/list_of_supported_exasol_functions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,256 @@
# List of Supported Exasol Functions

Here you can find a list of supported(or partly supported) functions for the Exasol database.

- [Scalar Functions](#scalar-functions)
- [Aggregate Functions](#aggregate-functions)
-

## Scalar Functions
#### Numeric Functions

- ABS
- ACOS
- ASIN
- ATAN
- ATAN2
- CEIL
- COS
- COSH
- COT
- DEGREES
- DIV
- EXP
- FLOOR
- LN
- LOG
- LOG10
- LOG2
- MOD
- PI
- POWER
- RADIANS
- RANDOM
- ROUND
- SIGN
- SIN
- SINH
- SQRT
- TAN
- TANH
- TRUNC

#### String Functions

- ASCII
- BIT_LENGTH
- CHARACTER_LENGTH
- CHAR
- COLOGNE_PHONETIC
- CONCAT
- DUMP
- EDIT_DISTANCE
- INITCAP
- INSERT
- INSTR
- LCASE
- LEFT
- LENGTH
- LOCATE
- LOWER
- LPAD
- LTRIM
- MID
- OCTET_LENGTH
- REGEXP_INSTR
- REGEXP_REPLACE
- REGEXP_SUBSTR
- REPEAT
- REPLACE
- REVERSE
- RIGHT
- RPAD
- RTRIM
- SOUNDEX
- SUBSTR
- TRANSLATE
- TRIM
- UCASE
- UNICODE
- UNICODECHR
- UPPER

#### Date/Time Functions

- ADD_DAYS
- ADD_HOURS
- ADD_MINUTES
- ADD_MONTHS
- ADD_SECONDS
- ADD_WEEKS
- ADD_YEARS
- CONVERT_TZ
- CURRENT_DATE
- CURRENT_TIMESTAMP
- DAY
- DAYS_BETWEEN
- DBTIMEZONE
- FROM_POSIX_TIME
- HOUR
- HOURS_BETWEEN
- LOCALTIMESTAMP
- MINUTE
- MINUTES_BETWEEN
- MONTH
- MONTHS_BETWEEN
- NOW
- NUMTODSINTERVAL
- NUMTOYMINTERVAL
- POSIX_TIME
- SECOND
- SECONDS_BETWEEN
- SESSIONTIMEZONE
- SYSDATE
- SYSTIMESTAMP
- WEEK
- YEAR
- YEARS_BETWEEN

#### Geospatial Functions

- ST_AREA
- ST_BOUNDARY
- ST_BUFFER
- ST_CENTROID
- ST_CONTAINS
- ST_CONVEXHULL
- ST_CROSSES
- ST_DIFFERENCE
- ST_DIMENSION
- ST_DISJOINT
- ST_DISTANCE
- ST_ENDPOINT
- ST_ENVELOPE
- ST_EQUALS
- ST_EXTERIORRING
- ST_FORCE2D
- ST_GEOMETRYN
- ST_GEOMETRYTYPE
- ST_INTERIORRINGN
- ST_INTERSECTION
- ST_INTERSECTS
- ST_ISCLOSED
- ST_ISEMPTY
- ST_ISRING
- ST_ISSIMPLE
- ST_LENGTH
- ST_NUMGEOMETRIES
- ST_NUMINTERIORRINGS
- ST_NUMPOINTS
- ST_OVERLAPS
- ST_SETSRID
- ST_POINTN
- ST_STARTPOINT
- ST_SYMDIFFERENCE
- ST_TOUCHES
- ST_TRANSFORM
- ST_UNION
- ST_WITHIN
- ST_X
- ST_Y

#### Bitwise Function

- BIT_AND
- BIT_CHECK
- BIT_LROTATE
- BIT_LSHIFT
- BIT_NOT
- BIT_OR
- BIT_RROTATE
- BIT_RSHIFT
- BIT_SET
- BIT_TO_NUM
- BIT_XOR

#### Conversion Functions

- IS_NUMBER
- IS_DATE
- IS_TIMESTAMP
- IS_BOOLEAN
- IS_DSINTERVAL
- IS_YMINTERVAL
- TO_CHAR
- TO_DATE
- TO_DSINTERVAL
- TO_NUMBER
- TO_TIMESTAMP
- TO_YMINTERVAL

#### Other Scalar Functions

- COALESCE
- CURRENT_SCHEMA
- CURRENT_SESSION
- CURRENT_STATEMENT
- CURRENT_USER
- DECODE
- GREATEST
- HASH_MD5
- HASH_SHA
- HASH_SHA256
- HASH_SHA512
- HASH_TIGER
- IPROC
- LEAST
- NULLIF
- NULLIFZERO
- NPROC
- NVL
- NVL2
- ROWNUM
- ROWID
- SCOPE_USER
- SYS_GUID
- USER
- VALUE2PROC
- ZEROIFNULL

## Aggregate Functions

- APPROXIMATE_COUNT_DISTINCT
- AVG
- CORR
- COUNT
- COVAR_POP
- COVAR_SAMP
- FIRST_VALUE
- GROUP_CONCAT
- LAST_VALUE
- MAX
- MEDIAN
- MIN
- REGR_SLOPE
- REGR_INTERCEPT
- REGR_COUNT
- REGR_R2
- REGR_AVGX
- REGR_AVGY
- REGR_SXX
- REGR_SXY
- REGR_SYY
- STDDEV
- STDDEV_POP
- STDDEV_SAMP
- SUM
- VAR_POP
- VAR_SAMP
- VARIANCE

## Analytic Functions

- ANY
- EVERY
- LISTAGG
37 changes: 29 additions & 8 deletions doc/user_guide/statements/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

You can construct [`SELECT`](https://docs.exasol.com/sql/select.htm) SQL statements using the `Select` class.

## Creating `SELECT` Commands
## Creating `SELECT` Statements

You can create a basic `SELECT` like this:

Expand All @@ -13,16 +13,20 @@ select.from().table("schemaA.tableA");
select.limit(10);
```

### `SELECT` components
### `SELECT` Components

Here you can find a list of supported `SELECT` statement's components:

- derived column (field, function, arithmetic expression, etc)
- `FROM` clause
- [Derived column](#derived-column) (field, function, arithmetic expression, etc)
- [`FROM` clause](#from-clause)
- [`WHERE` clause](#where-clause)
- [`LIMIT` clause](#limit-clause)
- [`GROUP BY` clause](#group-by-clause)
- [`ORDER BY` clause](#order-by-clause)

#### Derived Column

A `SELECT` statement can contain one or more derived columns. Here we describe all supported types of a derived column.
A `SELECT` statement can contain one or more derived columns. Here we describe all supported types of derived columns.

- `field` represents a column in a table. You can create one or more fields using a method `field( ... )` of the `Select` class.

Expand All @@ -42,8 +46,9 @@ final Select selectWithOneField = StatementFactory.getInstance().select() //
```

- `function` is a pre-defined function executing against a database. Create functions using a `function( ... )` method.
To create a function you need a name of a function which is included into the list of supported functions of the SSB.
You can also add a name for a derived field that contains a function.
You can only create functions that the SSB supports. Check [the list of supported functions](../list_of_supported_exasol_functions.md).

You can also set a name for a derived field that contains a function.
A function takes any number of [`ValueExpression`](../../../src/main/java/com/exasol/sql/expression/ValueExpression.java)
and renders them in the order they were added.

Expand All @@ -57,7 +62,7 @@ final Select select = StatementFactory.getInstance().select() //

- `arithmetic expression` is a binary arithmetic expression with one of the following arithmetic operator: +, -, *, /.
Add an arithmetic expression using an `arithmeticExpression( ... )` method.
You can also add a name for a derived field that contains an arithmetic expression.
You can also set a name for a derived field that contains an arithmetic expression.

```java
final Select select = StatementFactory.getInstance().select() //
Expand Down Expand Up @@ -134,9 +139,25 @@ select.limit(1);
A `SELECT` statement can contain one `GROUP BY` clause.
To start a `GROUP BY` clause, use a method `groupBy()` of the `Select` class.

The `GROUP BY` clause supports a `HAVING` clause. To add it use a `having( ... )` method.

```java
Select select = StatementFactory.getInstance().select();
select.all().from().table("t");
select.groupBy(column("t", "city"), column("t", "order"), column("t", "price"))
.having(lt(column("t", "price"), integerLiteral(10)));
```

#### `ORDER BY` clause

A `SELECT` statement can contain one `ORDER BY` clause.

To start a `ORDER BY` clause, use a method `orderBy()` of the `Select` class.
TYou can also use `nullsFirst()`/`nullsLast()` and `asc()`/`desc()` methods within this clause.


```java
Select select = StatementFactory.getInstance().select();
select.all().from().table("t");
select.select.orderBy(column("t", "city"), column("t", "price")).nullsFirst().asc();
```
2 changes: 0 additions & 2 deletions src/test/java/com/exasol/sql/dql/select/TestSelect.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import org.junit.jupiter.api.Test;

import com.exasol.sql.StatementFactory;
import com.exasol.sql.dql.select.rendering.SelectRenderer;
import com.exasol.sql.rendering.StringRendererConfig;

class TestSelect {
private Select select;
Expand Down

0 comments on commit adffe93

Please sign in to comment.