Commit b1e6c379 by Venkatesh Seetharam

Fix bugs in gremlin translator to use persistence strategy for select attributes

parent 6edfdb77
......@@ -31,6 +31,7 @@ import org.apache.hadoop.metadata.repository.graph.GraphProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import scala.Option;
import scala.Some;
import scala.collection.immutable.List;
import javax.inject.Inject;
......@@ -51,7 +52,7 @@ public class HiveLineageService implements LineageService {
private static final String HIVE_PROCESS_OUTPUT_ATTRIBUTE_NAME = "outputTables";
private static final Option<List<String>> SELECT_ATTRIBUTES =
Option.<List<String>>apply(List.<String>fromArray(new String[]{"name"}));
Some.<List<String>>apply(List.<String>fromArray(new String[]{"name"}));
private final TitanGraph titanGraph;
private final DefaultGraphPersistenceStrategy graphPersistenceStrategy;
......
......@@ -187,9 +187,10 @@ class GremlinTranslator(expr: Expression,
case ClassExpression(clsName) => s"""has("${gPersistenceBehavior.typeAttributeName}","$clsName")"""
case TraitExpression(clsName) => s"""has("${gPersistenceBehavior.typeAttributeName}","$clsName")"""
case fe@FieldExpression(fieldName, fInfo, child) if fe.dataType.getTypeCategory == TypeCategory.PRIMITIVE => {
val fN = "\"" + gPersistenceBehavior.fieldNameInVertex(fInfo.dataType, fInfo.attrInfo) + "\""
child match {
case Some(e) => s"${genQuery(e, inSelect)}.$fieldName"
case None => fieldName
case Some(e) => s"${genQuery(e, inSelect)}.$fN"
case None => s"$fN"
}
}
case fe@FieldExpression(fieldName, fInfo, child)
......
......@@ -464,7 +464,7 @@ public class QuickStart {
"Table as _loop0 loop (hive_process outputTables) withPath",
"Table as src loop (hive_process outputTables) as dest select src.name as srcTable, dest.name as destTable withPath",
*/
"Table as t, columns where t.name=\"sales_fact\"",
"Table where name=\"sales_fact\", columns as column select column.name, column.dataType, column.comment",
};
}
......
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