-
Notifications
You must be signed in to change notification settings - Fork 0
Functions_new
LINQ to AQL is a .NET client library and LINQ provider for AsterixDB.
It generates AQL expressions from LINQ expressions and executes them against an AsterixDB endpoint, bringing idiomatic and type safe LINQ queries to AsterixDB.
Once a prerelease version is released, it will be available from NuGet
The below sections describe how to use each supported AQL function in LINQ to AQL.
Functions marked "remote only" cannot be evaluated locally. Attempting to do so will result in an AsterixRemoteOnlyException
.
- Numeric Functions
- String Functions
- Aggregate Functions
- Spatial Functions
- Similarity Functions
- Tokenizing Functions
- Other Functions
All the supported AQL numeric functions are mapped to System.Math
.
###Example
dv.FacebookUsers.Where(u => Math.Abs(u.id) > 32);
generates
for $u in dataset FacebookUsers where (abs($u.id) > 32) return $u
###Supported Numeric Functions
- abs :
Math.Abs
- ceiling :
Math.Ceiling
- floor :
Math.Floor
- round is currently not supported
- round-half-to-even
Any of
Math.Round(double)
Math.Round(decimal)
-
Math.Round(double, MidpointRounding.ToEven)
Note that Math.Round defaults to MidpointRounding.ToEven
All the supported AQL string functions are mapped to System.String
.
###Example
dv.FacebookUsers.Select(u => u.name[0]);
generates
for $u in dataset FacebookUsers return string-to-codepoint($u.name)[0]
###Supported String Functions
- string-to-codepoint
- string-to-codepoint(str) :
str.ToCharArray()
- string-to-codepoint(str)[0] :
str[0]
- string-to-codepoint(str) :
- codepoint-to-string :
new string(str)
- contains :
str.Contains("other")
- like is currently not supported
- starts-with :
str.StartsWith(otherStr)
- ends-with :
str.EndsWith("other")
- string-concat is currently not supported
- string-join :
string.Join(",", m.Messages)
- lowercase :
str.ToLower()
- uppercase is currently not supported
- matches is currently not supported
- replace is currently not supported
- string-length :
str.Length
- substring :
str.Substring(50, 10)
andstr.Substring(50)
- substring-before is currently not supported
- substring-after is currently not supported
All the supported AQL aggregate functions are mapped to extensions of IEnumerable<T>
in System.Linq
(normal LINQ aggregates).
###Example
dv.TwitterUsers.Select(i => i.friends_count).Sum()
generates
sum(for $i in dataset TwitterUsers return $i.friends_count)
###Supported Functions
- count :
Count()
- avg :
Average()
- sum :
Sum()
- min :
Min()
- max :
Max()
- sql-count is currently not supported
- sql-avg is currently not supported
- sql-sum is currently not supported
- sql-min is currently not supported
- sql-max is currently not supported
All the supported AQL spatial functions are mapped to LinqToAql.Spatial
.
###Example
dv.FacebookUsers.Select(u => new Line(new Point(u.id, 1.9), new Point(2.4, u.id)))
generates
for $u in dataset FacebookUsers return create-line(create-point($u.id, 1.9), create-point(2.4, $u.id))
For an example of each function, view the relevant tests.
###Supported Functions
- create-point :
new Point(x, y)
- create-line :
new Line(point1, point2)
- create-rectangle is currently not supported
- create-circle is currently not supported
- create-polygon is currently not supported
- get-x is currently not supported
- get-y is currently not supported
- get-points is currently not supported
- get-center is currently not supported
- get-radius is currently not supported
- spatial-distance :
point1.Distance(point2)
remote only - spatial-area is currently not supported
- spatial-intersect is currently not supported
- spatial-cell is currently not supported
All the supported AQL similarity functions are extension methods in LinqToAql.Similarity
.
###Example
dv.FacebookUsers.Where(u => u.name.EditDistanceCheck("Suzanna Tilson", 2))
generates
for $u in dataset FacebookUsers where edit-distance-check($u.name, \"Suzanna Tilson\", 2) return $u
###Supported Functions
- edit-distance :
str.EditDistance(otherStr)
ormyList.EditDistance(otherList)
remote only - edit-distance-check will remain not supported
- edit-distance-contains :
str.EditDistanceContains(other, 4)
orlist.EditDistanceContains(other, 3)
remote only - similarity-jaccard :
list.Jaccard(otherList)
remote only - similarity-jaccard-check will remain not supported
All the supported AQL tokenizing functions are mapped to System.String
.
###Example
dv.FacebookUsers.Select(u => u.name.Split(' '));
generates
for $u in dataset FacebookUsers return word-tokens($u.name)
###Supported Functions
- word-tokens :
myString.Split(' ')
###Example
IQueryable<FacebookUser> query = from fbu in dv.FacebookUsers
where (fbu.employment.Any(e => e.EndDate == null))
select fbu;
generates
for $fbu in dataset FacebookUsers where (some $e in $fbu.employment satisfies is-null($e.end-date)) return $fbu
###Supported Functions
- create-uuid is currently not supported
- is-null :
null
or!myVar.HasValue
for nullable types - is-system-null is currently not supported
- len is currently not supported
- not is currently not supported
- range is currently not supported
- switch-case is currently not supported
- deep-equal is currently not supported