Skip to main content
Use the format_apl function in APL to convert a parsed APL query structure (stored as a dynamic object) back into its string representation. This is the inverse operation of parse_apl, allowing you to reconstruct APL query text from its parsed form. You use format_apl when you need to programmatically build or modify APL queries, inspect query structure, or transform parsed query representations back into executable query strings. This is particularly useful for query generation, query templating systems, and programmatic query manipulation in automation workflows.

Usage

Syntax

format_apl(apl_dict)

Parameters

NameTypeDescription
apl_dictdynamicA dynamic object representing the parsed structure of an APL query, typically generated by the parse_apl function.

Returns

A string containing the APL query reconstructed from the parsed structure. The returned query string is syntactically valid and can be executed.

Use case examples

  • Log analysis
  • OpenTelemetry traces
  • Security logs
Use format_apl to generate dynamic queries based on stored query templates for log analysis automation.Query
['sample-http-logs']
| extend base_query = parse_apl('["sample-http-logs"] | summarize count() by status')
| extend query_text = format_apl(base_query)
| project query_text
| take 1
Output
query_text
[‘sample-http-logs’] | summarize count() by status
This query demonstrates how to parse and reformat APL queries, useful for query templating and generation systems.
  • parse_apl: Use parse_apl to convert APL query strings into structured dynamic objects. Use format_apl to convert those objects back into query strings.
  • format_sql: Use format_sql to format SQL queries from parsed structures. Use format_apl for APL query formatting.
  • parse_json: Use parse_json to parse JSON strings. Use parse_apl and format_apl specifically for APL query structures.
  • dynamic_to_json: Use dynamic_to_json to convert dynamic objects to JSON strings. Use format_apl to convert parsed query structures back to APL syntax.