Skip to content

Commit 1420e8f

Browse files
committed
merge conflict fix
Signed-off-by: Asif Bashar <[email protected]>
1 parent 7e6e9ac commit 1420e8f

File tree

1 file changed

+0
-83
lines changed

1 file changed

+0
-83
lines changed

docs/user/ppl/functions/conversion.rst

Lines changed: 0 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -79,86 +79,3 @@ Cast function can be chained::
7979
| True |
8080
+-------+
8181

82-
TOSTRING
83-
-----------
84-
85-
Description
86-
>>>>>>>>>>>
87-
The following usage options are available, depending on the parameter types and the number of parameters.
88-
89-
Usage with format type: tostring(ANY, [format]): Converts the value in first argument to provided format type string in second argument. If second argument is not provided, then it converts to default string representation.
90-
Return type: string
91-
92-
Usage for boolean parameter without format type tostring(boolean): Converts the string to 'TRUE' or 'FALSE'.
93-
Return type: string
94-
95-
You can use this function with the eval commands and as part of eval expressions. If first argument can be any valid type , second argument is optional and if provided , it needs to be format name to convert to where first argument contains only numbers. If first argument is boolean, then second argument is not used even if its provided.
96-
97-
Format types:
98-
99-
a) "binary" Converts a number to a binary value.
100-
b) "hex" Converts the number to a hexadecimal value.
101-
c) "commas" Formats the number with commas. If the number includes a decimal, the function rounds the number to nearest two decimal places.
102-
d) "duration" Converts the value in seconds to the readable time format HH:MM:SS.
103-
e) "duration_millis" Converts the value in milliseconds to the readable time format HH:MM:SS.
104-
105-
The format argument is optional and is only used when the value argument is a number. The tostring function supports the following formats.
106-
107-
Basic examples:
108-
109-
You can use this function to convert a number to a string of its binary representation.
110-
Example::
111-
112-
os> source=EMP | eval salary_binary = tostring(SAL, "binary") | fields ENAME, salary_binary, SAL
113-
fetched rows / total rows = 1/1
114-
+---------------+------------------+------------+
115-
| ENAME | salary_binary | SAL |
116-
|---------------+------------------+------------+
117-
| SMITH | 1001110001000000 | 80000.00 |
118-
+---------------+------------------+------------+
119-
120-
121-
You can use this function to convert a number to a string of its hex representation.
122-
Example::
123-
124-
os> source=EMP | eval salary_hex = tostring(SAL, "hex") | fields ENAME, salary_hex, SAL
125-
fetched rows / total rows = 1/1
126-
+---------------+---------------+------------+
127-
| ENAME | salary_hex | SAL |
128-
|---------------+------------------+---------+
129-
| SMITH | 13880 | 80000.00 |
130-
+---------------+---------------+------------+
131-
132-
The following example formats the column totalSales to display values with commas.
133-
Example::
134-
135-
os> source=EMP | eval salary_commas = tostring(SAL, "commas") | fields ENAME, salary_commas, SAL
136-
fetched rows / total rows = 1/1
137-
+---------------+------------------+------------+
138-
| ENAME | salary_commas | SAL |
139-
|---------------+------------------+------------+
140-
| SMITH | 80,000 | 80000.00 |
141-
+---------------+------------------+------------+
142-
143-
The following example converts number of seconds to HH:MM:SS format representing hours, minutes and seconds.
144-
Example::
145-
146-
os> source=EMP | eval duration = tostring(6500, "duration") | fields ENAME, duration
147-
fetched rows / total rows = 1/1
148-
+---------------+-------------+
149-
| ENAME | duration |
150-
|---------------+-------------+
151-
| SMITH | 01:48:20 |
152-
+---------------+-------------+
153-
154-
The following example for converts boolean parameter to string.
155-
Example::
156-
157-
os> source=people | eval `boolean_str` = tostring(1=1)| fields `boolean_str`
158-
fetched rows / total rows = 1/1
159-
160-
+---------------------+
161-
| boolean_str |
162-
|---------------------+
163-
| TRUE |
164-
+---------------------+

0 commit comments

Comments
 (0)