-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for property filters, edge filters, and chaining to V3 node. Also fixes the property api to support empty responses. I ended up adding 6 SQL statements: - out arc, single hop - out arc, chained hops - in arc, single hop - in arc, chained hop - shared subquery for filtering properties - shared subquery for filtering edges I split up the single vs chained hops because it was taking too long to return the full response for chained hops. (This comes from processing the edge path, which can be very large and costly.) Instead I only return the name and dcid of the leaf node (and not provenance or types). This is consistent with the current v2 node behavior. I set the limit for chained hops to 10, which can take anywhere from a few hundred milliseconds to ~5 seconds for some of the examples I tested. Adding filters will increase the time too. Still TODO: support pagination, probably test this more
- Loading branch information
Showing
18 changed files
with
684 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
internal/server/spanner/golden/query/get_node_edges_in_bracket_props.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"EarthquakeEvent": [ | ||
{ | ||
"SubjectID": "EarthquakeEvent", | ||
"Predicate": "naturalHazardType", | ||
"ObjectID": "Annual_ExpectedLoss_NaturalHazardImpact_EarthquakeEvent", | ||
"ObjectValue": "", | ||
"Provenance": "dc/base/HumanReadableStatVars", | ||
"Name": "Annual Expected Loss from Natural Hazard Impact: Earthquake", | ||
"Types": [ | ||
"StatisticalVariable" | ||
] | ||
}, | ||
{ | ||
"SubjectID": "EarthquakeEvent", | ||
"Predicate": "naturalHazardType", | ||
"ObjectID": "FemaNaturalHazardRiskIndex_NaturalHazardImpact_EarthquakeEvent", | ||
"ObjectValue": "", | ||
"Provenance": "dc/base/HumanReadableStatVars", | ||
"Name": "FEMA National Risk Index for Natural Hazard Impact: Earthquake", | ||
"Types": [ | ||
"StatisticalVariable" | ||
] | ||
}, | ||
{ | ||
"SubjectID": "EarthquakeEvent", | ||
"Predicate": "naturalHazardType", | ||
"ObjectID": "NaturalHazardRiskScore_SuperfundSite_EarthquakeEvent", | ||
"ObjectValue": "", | ||
"Provenance": "dc/base/HumanReadableStatVars", | ||
"Name": "Natural Hazard Risk Score of Superfund Site: Earthquake Event", | ||
"Types": [ | ||
"StatisticalVariable" | ||
] | ||
}, | ||
{ | ||
"SubjectID": "EarthquakeEvent", | ||
"Predicate": "domainIncludes", | ||
"ObjectID": "affectedPlace", | ||
"ObjectValue": "", | ||
"Provenance": "dc/base/BaseSchema", | ||
"Name": "affectedPlace", | ||
"Types": [ | ||
"Property" | ||
] | ||
} | ||
] | ||
} |
22 changes: 22 additions & 0 deletions
22
internal/server/spanner/golden/query/get_node_edges_in_chain.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"dc/g/Farm_FarmInventoryStatus": [ | ||
{ | ||
"SubjectID": "dc/g/Farm_FarmInventoryStatus", | ||
"Predicate": "specializationOf+", | ||
"ObjectID": "dc/g/Farm_FarmInventoryStatus-InventorySold", | ||
"ObjectValue": "", | ||
"Provenance": "", | ||
"Name": "Farm With Farm Inventory Status = Inventory Sold", | ||
"Types": [] | ||
}, | ||
{ | ||
"SubjectID": "dc/g/Farm_FarmInventoryStatus", | ||
"Predicate": "specializationOf+", | ||
"ObjectID": "dc/g/Farm_FarmInventoryStatus-InventorySold_FarmInventoryType", | ||
"ObjectValue": "", | ||
"Provenance": "", | ||
"Name": "Farm With Farm Inventory Status = Inventory Sold, Farm Inventory Type", | ||
"Types": [] | ||
} | ||
] | ||
} |
15 changes: 15 additions & 0 deletions
15
internal/server/spanner/golden/query/get_node_edges_in_filter.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"Farm": [ | ||
{ | ||
"SubjectID": "Farm", | ||
"Predicate": "populationType", | ||
"ObjectID": "Area_Farm_Melon", | ||
"ObjectValue": "", | ||
"Provenance": "dc/base/HumanReadableStatVars", | ||
"Name": "Area of Farm: Melon", | ||
"Types": [ | ||
"StatisticalVariable" | ||
] | ||
} | ||
] | ||
} |
15 changes: 15 additions & 0 deletions
15
internal/server/spanner/golden/query/get_node_edges_in_single_prop.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"EarthquakeEvent": [ | ||
{ | ||
"SubjectID": "EarthquakeEvent", | ||
"Predicate": "domainIncludes", | ||
"ObjectID": "affectedPlace", | ||
"ObjectValue": "", | ||
"Provenance": "dc/base/BaseSchema", | ||
"Name": "affectedPlace", | ||
"Types": [ | ||
"Property" | ||
] | ||
} | ||
] | ||
} |
3 changes: 3 additions & 0 deletions
3
internal/server/spanner/golden/query/get_node_edges_malicious.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"foo OR 1=1;": [] | ||
} |
24 changes: 24 additions & 0 deletions
24
internal/server/spanner/golden/query/get_node_edges_out_bracket_props.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"Person": [ | ||
{ | ||
"SubjectID": "Person", | ||
"Predicate": "subClassOf", | ||
"ObjectID": "Thing", | ||
"ObjectValue": "", | ||
"Provenance": "dc/base/BaseSchema", | ||
"Name": "Thing", | ||
"Types": [ | ||
"Class" | ||
] | ||
}, | ||
{ | ||
"SubjectID": "Person", | ||
"Predicate": "source", | ||
"ObjectID": "", | ||
"ObjectValue": "https://www.w3.org/wiki/WebSchemas/SchemaDotOrgSources", | ||
"Provenance": "dc/base/BaseSchema", | ||
"Name": "", | ||
"Types": [] | ||
} | ||
] | ||
} |
49 changes: 49 additions & 0 deletions
49
internal/server/spanner/golden/query/get_node_edges_out_chain.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"dc/g/Person_Gender": [ | ||
{ | ||
"SubjectID": "dc/g/Person_Gender", | ||
"Predicate": "specializationOf+", | ||
"ObjectID": "dc/g/Demographics", | ||
"ObjectValue": "", | ||
"Provenance": "", | ||
"Name": "Demographics", | ||
"Types": [] | ||
}, | ||
{ | ||
"SubjectID": "dc/g/Person_Gender", | ||
"Predicate": "specializationOf+", | ||
"ObjectID": "dc/g/Economy", | ||
"ObjectValue": "", | ||
"Provenance": "", | ||
"Name": "Economy", | ||
"Types": [] | ||
}, | ||
{ | ||
"SubjectID": "dc/g/Person_Gender", | ||
"Predicate": "specializationOf+", | ||
"ObjectID": "dc/g/Employment", | ||
"ObjectValue": "", | ||
"Provenance": "", | ||
"Name": "Employment and Business", | ||
"Types": [] | ||
}, | ||
{ | ||
"SubjectID": "dc/g/Person_Gender", | ||
"Predicate": "specializationOf+", | ||
"ObjectID": "dc/g/Health", | ||
"ObjectValue": "", | ||
"Provenance": "", | ||
"Name": "Health", | ||
"Types": [] | ||
}, | ||
{ | ||
"SubjectID": "dc/g/Person_Gender", | ||
"Predicate": "specializationOf+", | ||
"ObjectID": "dc/g/Root", | ||
"ObjectValue": "", | ||
"Provenance": "", | ||
"Name": "Data Commons Variables", | ||
"Types": [] | ||
} | ||
] | ||
} |
15 changes: 15 additions & 0 deletions
15
internal/server/spanner/golden/query/get_node_edges_out_filter.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"nuts/UKI1": [ | ||
{ | ||
"SubjectID": "nuts/UKI1", | ||
"Predicate": "typeOf", | ||
"ObjectID": "AdministrativeArea2", | ||
"ObjectValue": "", | ||
"Provenance": "dc/base/EuroGeos", | ||
"Name": "AdministrativeArea2", | ||
"Types": [ | ||
"Class" | ||
] | ||
} | ||
] | ||
} |
13 changes: 13 additions & 0 deletions
13
internal/server/spanner/golden/query/get_node_edges_out_single_prop.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"Person": [ | ||
{ | ||
"SubjectID": "Person", | ||
"Predicate": "extendedName", | ||
"ObjectID": "", | ||
"ObjectValue": "Person", | ||
"Provenance": "dc/base/BaseSchema", | ||
"Name": "", | ||
"Types": [] | ||
} | ||
] | ||
} |
Oops, something went wrong.