Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Select clause is not working in Atlas DSL

avatar
Rising Star

Hi,

Can anyone please help me in understanding SELECT clause in DSL? Following mentioned query returns no rows though there is an entity named as "Reporting" of type "DB" having attributes as name and owner.

DB where name="Reporting" select name, owner

screenshot-from-2017-07-10-17-49-58.png
1 ACCEPTED SOLUTION

avatar
Super Collaborator

@Saba Baig

The select lets you "select" a particular attribute of an entity

DB where name="Reporting" select name, owner

displays the name and owner of db whose name is "Reporting"

Currently UI doesn't display results but REST GET API call actually returns the result.

Example :

DSL query : hive_table name = "table1" select qualifiedName,owner

response :

{queryType: "DSL",
queryText: "`hive_table` name="table1" select qualifiedName,owner",
attributes: 
{name: 
["qualifiedName",
"owner"
],
values: 
[
["default.table1@cl1",
"atlas"
]
]
}
}

View solution in original post

15 REPLIES 15

avatar
Super Collaborator

@Saba Baig

The select lets you "select" a particular attribute of an entity

DB where name="Reporting" select name, owner

displays the name and owner of db whose name is "Reporting"

Currently UI doesn't display results but REST GET API call actually returns the result.

Example :

DSL query : hive_table name = "table1" select qualifiedName,owner

response :

{queryType: "DSL",
queryText: "`hive_table` name="table1" select qualifiedName,owner",
attributes: 
{name: 
["qualifiedName",
"owner"
],
values: 
[
["default.table1@cl1",
"atlas"
]
]
}
}

avatar
Rising Star

@Sharmadha Sainath Could you please also guide me how is it using groupby and other functions liek max, min with some example? Does their result reflects on UI or not? Also, what features e.g wildcards (? . * etc) are available in full-text provided by Atlas? and how can we use them (examples)?

avatar
Rising Star

Queries like this are also not returning anything e.g using groupby with select

19382-screenshot-from-2017-07-11-12-21-34.png

avatar
Rising Star

@Sharmadha Sainath could you please also tell me how does this works

`Log Data` ??? what am I supposed to write in single quotes and how do you explain the results?

avatar
Expert Contributor

@Saba Baig, you can search for any entities tagged with a particular tag name using the single quotes. for e.g. `Log Data` searches for all entities in atlas tagged as Log Data. Only classification name is supported in single quotes.

avatar
Rising Star

@Sharmadha Sainath can you please guide me on this? as the method "searchUsingDslQuery" from EntityDiscoveryService.java is getting the result of the fetched attributes but then it only adds the attributes to the object of AtlasSearchResult...neither an AtlasVertex nor contains theInstance or theTrait.... Could you please guide me on this?

avatar
Super Collaborator
@Saba BaigFew aggregate functions are not working in V2 APIs.

There are few Apache JIRAs filed for the same :

https://issues.apache.org/jira/browse/ATLAS-1874

https://issues.apache.org/jira/browse/ATLAS-1639

However V1 APIs work perfectly .

For example :

Query : hive_table groupby(owner) select owner,count()

URL encoded :

http://localhost:21000/api/atlas/discovery/search/dsl?limit=25&query=hive_table+groupby(owner)+selec... 
Response :

{requestId: "pool-2-thread-9 - 8a45b7a6-0cd9-4e9d-8b71-66e313f5abf1",
query: "hive_table groupby(owner) select owner,count()",
queryType: "dsl",
count: 2,
results: 
[
{$typeName$: "__tempQueryResultStruct74",
count(): 9,
owner: "hrt_qa"
},

{$typeName$: "__tempQueryResultStruct74",
count(): 2,
owner: "anonymous"
}
],
dataType: 
{typeName: "__tempQueryResultStruct74",
typeDescription: null,
typeVersion: "1.0",
attributeDefinitions: 
[
{name: "owner",
dataTypeName: "string",
multiplicity: 
{lower: 0,
upper: 1,
isUnique: false
},
isComposite: false,
isUnique: false,
isIndexable: false,
reverseAttributeName: null
},

{name: "count()",
dataTypeName: "long",
multiplicity: 
{lower: 0,
upper: 1,
isUnique: false
},
isComposite: false,
isUnique: false,
isIndexable: false,
reverseAttributeName: null
}
]
}
}

This query groups the owner of hive_table and and lists the owner ,count in each group . The concept is similar to that of SQL.

Since the UI currently uses V2 query , you may not see the results on UI. But you can always rely on REST APIs.

For this particular kind of queries , please use V1 APIs for now .

avatar
Super Collaborator

@Saba Baig

>> Also, what features e.g wildcards (? . * etc) are available in full-text provided by Atlas? and how can we use them (examples)?

Atlas uses lucene query syntax for its full text search (basic search).

Please refer lucene query usage here :

http://lucene.apache.org/core/4_1_0/queryparser/org/apache/lucene/queryparser/classic/package-summar...

Example:

If I have 3 hive_table entities in Atlas , table_a , table_b , table_ab

Query :
1)
type = hive_table , query = table_?

http://localhost:21000/api/atlas/v2/search/basic?limit=25&excludeDeletedEntities=true&query=table_?&...

Returns 2 entities (table_a , table_b)

2)
type = hive_table , query = table_*

http://localhost:21000/api/atlas/v2/search/basic?limit=25&excludeDeletedEntities=true&query=table_*&...

Returns 3 entities (table_a , table_b , table_ab)

I hope this example makes it clear ...

Note : Wild card search can be done on UI itself.

avatar
Rising Star

@Sharmadha Sainath

I have an entity of type "Table" named as "sales_fact". I tried to get that using api

http://localhost:21000/api/atlas/v2/search/basic?limit=25&includeDeletedEntities=true&query=sales_fa...
=====Response =====
{  "queryType": "BASIC",  "type": "Table",  "entities": [  {  "typeName": "Table",  "attributes": {  "owner": "Joe",  "qualifiedName": "sales_fact",  "name": "sales_fact",  "description": "sales fact table"  },  "guid": "c9838518-041f-4759-b3e5-01147b1526d1",  "status": "ACTIVE",  "displayText": "sales_fact",  "classificationNames": [  "Fact"  ]  }  ]}

But when I tried to the same search (Basic using query) I typed sales_fa?t and I got invalid Expression. I added a breakpoint in the API but it was never called. I think there is some validation applied on that field that omits any character like ? from the query before submitting it to API. Please guide.

I think, this could be the reason

Apache Lucene Analysis Pipeline

19387-screenshot-from-2017-07-11-16-14-35.png