Commit 95675ad4 by Harish Butani

tests and minor fixes for Hive Lineage and WhereUsed

parent cb5ceb13
......@@ -66,7 +66,7 @@ trait ClosureQuery {
def toExpr : Expression = this match {
case r : Relation => id(r.attributeName)
case rr : ReverseRelation => id(rr.typeName)
case rr : ReverseRelation => id(s"${rr.typeName}->${rr.attributeName}")
}
def toFieldName : String = this match {
......
......@@ -317,7 +317,7 @@ class QueryLexer(val keywords: Seq[String], val delims: Seq[String]) extends Std
override def identChar = letter | elem('_')
def identifier = identChar ~ (identChar | digit).* ^^ { case first ~ rest => (first :: rest).mkString} |
'`' ~> chrExcept('\n', EofCh).* <~ '`' ^^ {
'`' ~> chrExcept('`', '\n', EofCh).* <~ '`' ^^ {
_ mkString ""
}
......
......@@ -115,6 +115,8 @@ object TypeUtils {
}
}
val FIELD_QUALIFIER = "(.*?)(->.*)?".r
/**
* Given a ComposedType `t` and a name resolve using the following rules:
* - if `id` is a field in `t` resolve to the field
......@@ -142,8 +144,18 @@ object TypeUtils {
}
try {
val idTyp = typSystem.getDataType(classOf[IDataType[_]], id)
val FIELD_QUALIFIER(clsNm, rest) = id
val idTyp = typSystem.getDataType(classOf[IDataType[_]], clsNm)
val idTypFMap = fieldMapping(idTyp)
if (rest != null ) {
val attrNm = rest.substring(2)
if (idTypFMap.get.fields.containsKey(attrNm)) {
return Some(FieldInfo(typ,idTypFMap.get.fields.get(attrNm), idTyp))
}
}
if (idTypFMap.isDefined) {
import scala.collection.JavaConversions._
val fields: Seq[AttributeInfo] = idTypFMap.get.fields.values().filter { aInfo =>
......
......@@ -86,22 +86,31 @@ class GremlinTest2 extends FunSuite with BeforeAndAfterAll with BaseGremlinTest
validateJson(r)
}
// test("testLineageAllSelectWithPathFromParser2") {
// val p = new QueryParser
// val e = p("Table as src loop (LoadProcess inputTables) as dest " +
// "select src.name as srcTable, dest.name as destTable withPath").right.get
// //Table as src loop (LoadProcess where LoadProcess.outputTable) as dest select src.name as srcTable, dest.name as destTable withPath
// val r = QueryProcessor.evaluate(e, g)
// validateJson(r)
// }
//
// test("testHighLevelLineage") {
// val r = HiveLineageQuery("Table", "sales_daily_mv",
// "LoadProcess",
// "inputTables",
// "outputTable",
// None, Some(List("name")), true, GraphPersistenceStrategy1, g).evaluate()
// validateJson(r)
// }
test("testLineageAllSelectWithPathFromParser2") {
val p = new QueryParser
val e = p("Table as src loop (`LoadProcess->outputTable` inputTables) as dest " +
"select src.name as srcTable, dest.name as destTable withPath").right.get
val r = QueryProcessor.evaluate(e, g)
validateJson(r)
}
test("testHighLevelLineage") {
val r = HiveLineageQuery("Table", "sales_fact_monthly_mv",
"LoadProcess",
"inputTables",
"outputTable",
None, Some(List("name")), true, GraphPersistenceStrategy1, g).evaluate()
validateJson(r)
}
test("testHighLevelWhereUsed") {
val r = HiveWhereUsedQuery("Table", "sales_fact",
"LoadProcess",
"inputTables",
"outputTable",
None, Some(List("name")), true, GraphPersistenceStrategy1, g).evaluate()
validateJson(r)
}
}
\ No newline at end of file
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