ATLAS-5148: This example DSL query given in documentation doesn't work #500
+49
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Problem Description (Before Fix)
Query:
Table groupby(owner)
Conclusion: Works
Query:
Table groupby(createTime)
Conclusion: Returns no records
Both owner (String) and createTime (Date/Long) attributes exist on the same hive_table entities.
Query:
Table groupby(createTime) select owner, name, max(createTime)
Conclusion: Returns no records
Similar query using a String attribute works as expected:
Table groupby(owner) select owner, count()
Conclusion: Works
GROUP BY keys were handled only for String data types
When grouping by non-String attributes (Date/Long), valid group keys were dropped during result processing
This resulted in empty results even though grouping succeeded internally
Fix Description (After Fix)
Updated method:
AtlasJanusGraphTraversal.getAtlasVertexMap()
Logic change:
String keyStr = (key instanceof String) ? (String) key : String.valueOf(key);
This converts GROUP BY keys of type Long, Date, Integer, etc. into String. Prevents valid GROUP BY results from being dropped
Query:
Table groupby(createTime)
Conclusion: Returns grouped results
The following queries now return valid results:
Table groupby(createTime) select owner, name, min(createTime)
Table groupby(createTime) select owner, name, max(createTime)
How was this patch tested?
. UI testing
. Local Build (jdk8/17)
. PC: https://ci-builds.apache.org/job/Atlas/job/PreCommit-ATLAS-Build-Test/2029/
. CI workflow