You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/using-gitbase/examples.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -181,13 +181,13 @@ or through a specific property:
181
181
SELECT file_path, uast_extract(uast(blob_content, language(file_path), "//FuncLit"), "internalRole") FROM files;
182
182
```
183
183
184
-
As result, you will get an array of arrays showing a list of the retrieved informationfor each of the given nodes:
184
+
As result, you will get an array showing a list of the retrieved information. Each element in the list matches a node in the given sequence of nodes having a value for that property. It means that the length of the properties list may not be equal to the length of the given sequence of nodes:
## How to formulate XPath queries when use uast and uast_xpath functions
34
+
35
+
Have a look at the [bblfsh docs](https://docs.sourced.tech/babelfish/using-babelfish/uast-querying) to query UASTs with XPath.
36
+
37
+
## How to use uast_extract
38
+
39
+
Check out the [UAST specification](https://docs.sourced.tech/babelfish/uast/uast-specification) to know what an UAST node represents.
40
+
41
+
`uast_extracts` accepts special selectors to match common node properties:
42
+
43
+
-`@type`
44
+
-`@token`
45
+
-`@role`
46
+
-`@startpos`
47
+
-`@endpos`
48
+
49
+
Using these selectors as in,
50
+
51
+
> uast_extract(nodes_column, @common_selector)
52
+
53
+
you will extract the value of that property for each node.
54
+
55
+
Nodes that have no value for the requested property will not be present in any way in the final array. That is, having a sequence of nodes `[node-1, node-2, node-3]` and knowing that node-2 doesn't have a value for the requested property, the returned array will be `[prop-1, prop-3]`.
56
+
57
+
Also, if you want to retrieve values from a non common property, you can pass it directly
58
+
59
+
> uast_extract(nodes_column, 'some-property')
60
+
33
61
## Standard functions
34
62
35
63
You can check standard functions in [`go-mysql-server` documentation](https://github.com/src-d/go-mysql-server/tree/679d33772845593ce5fdf17925f49f2335bc8356#custom-functions).
0 commit comments