Skip to content

Commit 4442f9a

Browse files
committed
add CLP_GET_JSON_STRING docs
1 parent 3ddb9d8 commit 4442f9a

File tree

1 file changed

+39
-4
lines changed
  • presto-docs/src/main/sphinx/connector

1 file changed

+39
-4
lines changed

presto-docs/src/main/sphinx/connector/clp.rst

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,15 +325,16 @@ CLP Functions
325325
*************
326326

327327
Semi-structured logs can have many potential keys, which can lead to very wide Presto tables. To keep table metadata
328-
concise and still preserve access to dynamic fields, the connector provides two sets of functions that are specific to
328+
concise and still preserve access to dynamic fields, the connector provides three sets of functions that are specific to
329329
the CLP connector. These functions are not part of standard Presto SQL.
330330

331331
- JSON path functions (e.g., ``CLP_GET_STRING``)
332332
- Wildcard column matching functions for use in filter predicates (e.g., ``CLP_WILDCARD_STRING_COLUMN``)
333+
- A function for retrieving the entire row in JSON format (i.e., ``CLP_GET_JSON_STRING``)
333334

334-
There is **no performance penalty** when using these functions. During query optimization, the connector rewrites these
335-
functions into references to concrete schema-backed columns or valid symbols in KQL queries. This avoids additional
336-
parsing overhead and delivers performance comparable to querying standard columns.
335+
For the first two sets of functions, there is **no performance overhead**. During query optimization, the connector
336+
rewrites these functions into references to concrete schema-backed columns or valid symbols in KQL queries. This avoids
337+
unnecessary parsing overhead and delivers performance comparable to querying standard columns.
337338

338339
Path-based Functions
339340
====================
@@ -439,6 +440,40 @@ Examples
439440
FROM clp.default.table_2
440441
WHERE CLP_WILDCARD_INT_COLUMN() = 1;
441442
443+
JSON String Function
444+
====================
445+
446+
The ``CLP_GET_JSON_STRING``` function provides a convenient way to retrieve the entire log record—including both
447+
schema-backed and dynamic fields—as a single JSON string. This enables users to inspect, debug, or export complete
448+
records in their raw JSON form.
449+
450+
Similar to the path-based and wildcard functions, this function is rewritten during query optimization to a special
451+
internal column. During query execution, this column is serialized into a JSON string that represents the full record.
452+
453+
.. function:: CLP_GET_JSON_STRING() -> varchar
454+
455+
Returns the full log record as a JSON string, preserving all schema-backed and dynamic fields.
456+
457+
.. note::
458+
459+
This function can only be used in the ``SELECT``` list to retrieve the complete JSON representation of each record.
460+
It cannot be used within filter predicates (``WHERE`` clause) or as an argument to other functions.
461+
462+
Examples
463+
--------
464+
465+
.. code-block:: sql
466+
467+
-- Retrieve each record as a JSON string
468+
SELECT CLP_GET_JSON_STRING()
469+
FROM clp.default.table_1
470+
LIMIT 10;
471+
472+
-- Retrieve JSON along with selected fields
473+
SELECT timestamp, CLP_GET_JSON_STRING()
474+
FROM clp.default.table_1
475+
WHERE CLP_WILDCARD_STRING_COLUMN() = 'error';
476+
442477
***********
443478
SQL support
444479
***********

0 commit comments

Comments
 (0)