@terascope/types / sql-interfaces / SQLDialect
Interface: SQLDialect
Defined in: packages/types/src/sql-interfaces.ts:168
The SQL that differs between engines.
The translator walks the xLucene AST; a dialect only renders the leaves and combines them with AND, OR and NOT. A caller can override one method without changing the translator.
Every predicate returned must be safe to embed in a larger expression, so anything with operator precedence is returned in parentheses.
Properties
| Property | Modifier | Type | Defined in |
|---|---|---|---|
name | readonly | string | packages/types/src/sql-interfaces.ts:169 |
Methods
and()
and(
expressions):string
Defined in: packages/types/src/sql-interfaces.ts:258
All of the expressions.
Parameters
| Parameter | Type |
|---|---|
expressions | string[] |
Returns
string
compare()
compare(
fieldExpr,operator,value,fieldType?):string
Defined in: packages/types/src/sql-interfaces.ts:230
One side of a range.
Parameters
| Parameter | Type |
|---|---|
fieldExpr | string |
operator | "gte" | "gt" | "lt" | "lte" |
value | unknown |
fieldType? | xLuceneFieldType |
Returns
string
equals()
equals(
fieldExpr,value,fieldType?):string
Defined in: packages/types/src/sql-interfaces.ts:227
Equality against a single value.
Parameters
| Parameter | Type |
|---|---|
fieldExpr | string |
value | unknown |
fieldType? | xLuceneFieldType |
Returns
string
exists()
exists(
fieldExpr):string
Defined in: packages/types/src/sql-interfaces.ts:244
The field has a value.
Parameters
| Parameter | Type |
|---|---|
fieldExpr | string |
Returns
string
fieldRef()
fieldRef(
field):string
Defined in: packages/types/src/sql-interfaces.ts:180
The column expression for an xLucene field path.
A dotted field can be a column named a.b or member b of a struct column a,
depending on how the engine stores nested data, so each dialect decides.
Parameters
| Parameter | Type |
|---|---|
field | string |
Returns
string
geoContainsPoint()
geoContainsPoint(
fieldExpr,point,isPointColumn):string
Defined in: packages/types/src/sql-interfaces.ts:308
A geo shape field that contains a point.
Parameters
| Parameter | Type |
|---|---|
fieldExpr | string |
point | GeoPoint |
isPointColumn | boolean |
Returns
string
geoPointDistance()
geoPointDistance(
fieldExpr,point):string
Defined in: packages/types/src/sql-interfaces.ts:287
The distance in meters from a geo-point field to a point, for sorting.
Parameters
| Parameter | Type |
|---|---|
fieldExpr | string |
point | GeoPoint |
Returns
string
geoPointInBoundingBox()
geoPointInBoundingBox(
fieldExpr,topLeft,bottomRight):string
Defined in: packages/types/src/sql-interfaces.ts:290
A geo-point field inside an axis-aligned bounding box.
Parameters
| Parameter | Type |
|---|---|
fieldExpr | string |
topLeft | GeoPoint |
bottomRight | GeoPoint |
Returns
string
geoPointParts()
geoPointParts(
fieldExpr):SQLGeoPointColumn
Defined in: packages/types/src/sql-interfaces.ts:189
The lat and lon members of a geo-point column.
Parameters
| Parameter | Type |
|---|---|
fieldExpr | string |
Returns
geoPointWithinDistance()
geoPointWithinDistance(
fieldExpr,point,meters):string
Defined in: packages/types/src/sql-interfaces.ts:282
A geo-point field within distance meters of a point.
Parameters
| Parameter | Type |
|---|---|
fieldExpr | string |
point | GeoPoint |
meters | number |
Returns
string
geoRelation()
geoRelation(
fieldExpr,shape,relation,isPointColumn):string
Defined in: packages/types/src/sql-interfaces.ts:300
A geo field related to a shape.
isPointColumn says whether the field holds a point or a shape, which decides how the
column becomes a geometry.
Parameters
| Parameter | Type |
|---|---|
fieldExpr | string |
shape | GeoShape |
relation | GeoShapeRelation |
isPointColumn | boolean |
Returns
string
ipEquals()
ipEquals(
fieldExpr,address):string
Defined in: packages/types/src/sql-interfaces.ts:267
An ip field equal to a single address, compared as addresses rather than as text.
Parameters
| Parameter | Type |
|---|---|
fieldExpr | string |
address | string |
Returns
string
ipInCIDR()
ipInCIDR(
fieldExpr,cidr):string
Defined in: packages/types/src/sql-interfaces.ts:264
An IP or CIDR value contained by the CIDR block of an ip field.
Parameters
| Parameter | Type |
|---|---|
fieldExpr | string |
cidr | string |
Returns
string
ipRangeContains()
ipRangeContains(
fieldExpr,value):string
Defined in: packages/types/src/sql-interfaces.ts:270
An ip_range field whose stored block contains the address or block.
Parameters
| Parameter | Type |
|---|---|
fieldExpr | string |
value | string |
Returns
string
ipRangeIntersects()
ipRangeIntersects(
fieldExpr,start?,end?):string
Defined in: packages/types/src/sql-interfaces.ts:277
An ip_range field whose stored block overlaps the queried address range.
Either bound may be absent, meaning unbounded on that side.
Parameters
| Parameter | Type |
|---|---|
fieldExpr | string |
start? | SQLIPRangeBound |
end? | SQLIPRangeBound |
Returns
string
limitOffset()
limitOffset(
size?,offset?):string
Defined in: packages/types/src/sql-interfaces.ts:209
The row-limiting clause, or an empty string when neither bound is set.
DuckDB and PostgreSQL both use LIMIT n OFFSET m, but other engines use
OFFSET … FETCH, so this is part of the dialect.
Parameters
| Parameter | Type |
|---|---|
size? | number |
offset? | number |
Returns
string
literal()
literal(
value,fieldType?):string
Defined in: packages/types/src/sql-interfaces.ts:186
A value rendered as a literal of the given xLucene field type.
Parameters
| Parameter | Type |
|---|---|
value | unknown |
fieldType? | xLuceneFieldType |
Returns
string
matchAll()
matchAll():
string
Defined in: packages/types/src/sql-interfaces.ts:221
TRUE - an empty query matches everything.
Returns
string
matchNone()
matchNone():
string
Defined in: packages/types/src/sql-interfaces.ts:224
FALSE - a query that cannot match anything.
Returns
string
not()
not(
expression):string
Defined in: packages/types/src/sql-interfaces.ts:255
Negation.
Not a bare NOT: Elasticsearch's must_not matches a document whose field is missing,
but SQL drops a row whose predicate is NULL, so a NULL result must become TRUE.
Parameters
| Parameter | Type |
|---|---|
expression | string |
Returns
string
or()
or(
expressions):string
Defined in: packages/types/src/sql-interfaces.ts:261
Any of the expressions.
Parameters
| Parameter | Type |
|---|---|
expressions | string[] |
Returns
string
orderBy()
orderBy(
sort?):string
Defined in: packages/types/src/sql-interfaces.ts:218
The ORDER BY terms, without the keyword, or '' for no ordering.
Direction and null placement are always written, because engine defaults for null
placement differ and none match DataFrame. An engine without
NULLS FIRST/NULLS LAST syntax can override this.
Parameters
| Parameter | Type |
|---|---|
sort? | readonly SQLSort[] |
Returns
string
projection()
projection(
readable,all):string
Defined in: packages/types/src/sql-interfaces.ts:201
The SELECT list for the readable fields.
This is where field restrictions are enforced, the SQL equivalent of Elasticsearch's
_source_excludes.
readable is the field paths that may be returned, and all is every path the type
config declares; both are needed to tell a fully readable column from a partly
readable one. An empty readable still returns rows, but with no data.
Parameters
| Parameter | Type |
|---|---|
readable | readonly string[] |
all | readonly string[] |
Returns
string
quoteIdentifier()
quoteIdentifier(
name):string
Defined in: packages/types/src/sql-interfaces.ts:172
Quote an identifier for use as a column reference.
Parameters
| Parameter | Type |
|---|---|
name | string |
Returns
string
regexp()
regexp(
fieldExpr,value,fieldType?):string
Defined in: packages/types/src/sql-interfaces.ts:241
An anchored regular expression match, as the Elasticsearch regexp query is.
Parameters
| Parameter | Type |
|---|---|
fieldExpr | string |
value | string |
fieldType? | xLuceneFieldType |
Returns
string
stringLiteral()
stringLiteral(
value):string
Defined in: packages/types/src/sql-interfaces.ts:183
A SQL string literal, escaped for this engine.
Parameters
| Parameter | Type |
|---|---|
value | string |
Returns
string
toText()
toText(
fieldExpr):string
Defined in: packages/types/src/sql-interfaces.ts:247
The value cast to text, for a query with no field.
Parameters
| Parameter | Type |
|---|---|
fieldExpr | string |
Returns
string
wildcard()
wildcard(
fieldExpr,value,fieldType?):string
Defined in: packages/types/src/sql-interfaces.ts:238
A wildcard match, given an xLucene wildcard value (* and ?).
Parameters
| Parameter | Type |
|---|---|
fieldExpr | string |
value | string |
fieldType? | xLuceneFieldType |
Returns
string