Commit 48a088fc by Harish Butani

BUG-32980 add is operator in Query DSL

parent 2f231bef
......@@ -523,7 +523,7 @@ object Expressions {
case class isTraitUnaryExpression(traitName: String, child: Expression)
extends Expression with UnaryNode {
// validate TraitName
typSystem.getDataType(classOf[ClassType], traitName)
typSystem.getDataType(classOf[TraitType], traitName)
lazy val dataType = {
if (!resolved) {
throw new UnresolvedException(this,
......
......@@ -57,6 +57,7 @@ trait QueryKeywords {
protected val GROUPBY = Keyword("groupby")
protected val LOOP = Keyword("loop")
protected val ISA = Keyword("isa")
protected val IS = Keyword("is")
protected val HAS = Keyword("has")
protected val AS = Keyword("as")
protected val TIMES = Keyword("times")
......@@ -195,7 +196,7 @@ class QueryParser extends StandardTokenParsers with QueryKeywords with Expressio
def compE =
arithE ~ (LT | LTE | EQ | NEQ | GT | GTE) ~ arithE ^^ { case l ~ op ~ r => l.compareOp(op)(r)} |
arithE ~ ISA ~ ident ^^ { case l ~ i ~ t => l.isTrait(t)} |
arithE ~ (ISA | IS) ~ ident ^^ { case l ~ i ~ t => l.isTrait(t)} |
arithE ~ HAS ~ ident ^^ { case l ~ i ~ f => l.hasField(f)} |
arithE
......
......@@ -57,6 +57,12 @@ class ParserTest extends BaseTest {
println(p("DB name = \"Reporting\"").right.get.toString)
}
@Test def testIsTrait: Unit = {
val p = new QueryParser
println(p("Table isa Dimension").right.get.toString)
println(p("Table is Dimension").right.get.toString)
}
@Test def test4: Unit = {
val p = new QueryParser
println(p("DB where (name = \"Reporting\") select name as _col_0, (createTime + 1) as _col_1").right.get.toString)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment