Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes made to the parser code for custom/external hive metastore #180

Open
wants to merge 1 commit into
base: release/2.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion docs/mappings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@ This directory contains a "gallery" of sample OpenLineage to Purview Mappings th
* [Snowflake](./snowflake.json)
* Supports mapping Snowflake tables in Purview.
* OpenLineage returns a DataSet with `"namespace":"snowflake://<snowflakeurl>","name":"<database>.<schema>.<table>`
* Microsoft Purview expects a fully qualified name of `snowflake://<snowflakeurl>/databases/<database>/schemas/<schema>/tables/<table>`
* Microsoft Purview expects a fully qualified name of `snowflake://<snowflakeurl>/databases/<database>/schemas/<schema>/tables/<table>`

## External hive metastore using azure SQL
* [external hive metastore](./ext-hive-metastore.json)
* Supports mapping hive metastore table hosted in azure sql DB.
* OpenLineage returns a hive asset types with `@AdbWorkspaceUrl`
* Microsoft Purview expects a fully qualified name of `<database>.<table>@<sqlserver-name>.database.windows.net`
* In case of multiple Adb workspace, contains-in or in condition will help to compare multiple values in one single mapping.
53 changes: 53 additions & 0 deletions docs/mappings/ext-hive-metastore.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[
{
"name": "hiveManagedTableDefault",
"parserConditions": [
{
"op1": "AdbWorkspaceUrl",
"compare": "contains-in",
"op2": "<adb workspace id1>|<adb workspace id2>|.....<adb workspace idn>"
},
{
"op1": "prefix",
"compare": "=",
"op2": "dbfs"
},
{
"op1": "nameGroups[0]",
"compare": "contains",
"op2": "hive/warehouse"
}
],
"qualifiedName": "default.{nameGroups[0].parts[3]}@<sqlserver-name>.database.windows.net",
"purviewDataType": "hive_table",
"purviewPrefix": "hive"
},
{
"name": "hiveManagedTableNotDefault",
"parserConditions": [
{
"op1": "AdbWorkspaceUrl",
"compare": "contains-in",
"op2": "<adb workspace id1>|<adb workspace id2>|.....<adb workspace idn>"
},
{
"op1": "prefix",
"compare": "=",
"op2": "dbfs"
},
{
"op1": "nameGroups[0]",
"compare": "contains",
"op2": "hive/warehouse"
},
{
"op1": "nameGroups[0].part",
"compare": ">",
"op2": "4"
}
],
"qualifiedName": "{nameGroups[0].part[3]}.{nameGroups[0].part[5]}@<sqlserver-name>.database.windows.net",
"purviewDataType": "hive_table",
"purviewPrefix": "hive"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,32 @@ private bool EvaluateConditions(List<ParserCondition> parserConditions, Dictiona
return true;
}

//The function ContainsIn and In will compare all worspace names. This can be used for custom hive metastore. for first match it will return true

private bool ContainsIn(string firstOp, string valOp)
{
var vstrVal = valOp.Split("|");
foreach (var item in vstrVal)
{
if (firstOp.Contains(item)) return true;
}
return false;
}

private bool In(string firstOp, string valOp)
{
var vstrVal = valOp.Split("|");

foreach (var item in vstrVal)
{
if (firstOp == item) return true;
}

return false;
}



private bool EvaluateCondition(ParserCondition parserCondition, Dictionary<string,object> olDynParts)
{
var firstOp = GetDynamicValue(parserCondition.Op1, olDynParts);
Expand All @@ -166,7 +192,11 @@ private bool EvaluateCondition(ParserCondition parserCondition, Dictionary<strin
case ">":
return int.Parse(firstOp) > int.Parse(parserCondition.ValOp2);
case "<":
return int.Parse(firstOp) < int.Parse(parserCondition.ValOp2);
return int.Parse(firstOp) < int.Parse(parserCondition.ValOp2);
case "contains-in":
return ContainsIn(firstOp, parserCondition.ValOp2);
case "in":
return In(firstOp, parserCondition.ValOp2);
}
return false;
}
Expand Down