Scala DSL for Specifying Filter Conditions
When loading data from HPE Data Fabric Database as an Apache Spark RDD, you can use Scala DSL to specify filter conditions. This section shows examples of these filter conditions.
In the following examples, a class named field is introduced to represent a
field in a condition. The field condition takes an argument as a String. The following table
shows conditions written using Scala DSL:
| Condition | Example |
|---|---|
| equality |
|
| greatherThan |
|
| notexists |
|
| IN |
|
| typeof |
|
| complex condition with and |
|
| another complex condition |
|
| between |
|
| predicate with equality check on Sequence of elements (representing array) |
|
| predicate with equality check on a map |
|
The HPE Data Fabric Database OJAI Connector for Apache Spark supports these predicates:
>>=<<====!=betweenexistsnotininnotexiststypeofnottypeoflikenotlikematchesnotmatchessizeOf
Here are examples for these operators:
field("a") > 10field("a") >= 10field("a") < 10field("a") <= 10field("a") === 10field("a") === Seq("aa", 10)field("a") === Map("aa" -> 10)field("a") != 10field("a") != Seq("aa", 10)field("a") != Map("aa" -> 10)field("a) between (10,20)field("a") existsfield("a") notin Seq(10,20)field("a") in Seq(10, 20)field("a") notexistsfield("a") typeof "INT"field("a") nottypeof "INT"field("a") like "%s"field("a") notlike "%s"field("a") matches "*s"field("a") notmatches "*s"
For typeof, these are the right-hand side values:
"INT""INTEGER""LONG""BOOLEAN""STRING""SHORT""BYTE""NULL""FLOAT""DOUBLE""DECIMAL""DATE""TIME""TIMESTAMP""INTERVAL""BINARY""MAP""ARRAY"
The sizeOf operator can have the following operations:
sizeOf(field("a")) === 10sizeOf(field("a")) < 10sizeOf(field("a")) > 10sizeOf(field("a")) >= 10sizeOf(field("a")) <= 10sizeOf(field("a")) != 10