clp icon indicating copy to clipboard operation
clp copied to clipboard

clp-s: Add support for escaping characters in KQL key names

Open gibber9809 opened this issue 4 months ago • 1 comments

Description

This PR adds support for using backslash to escape characters in KQL key names. The change is mostly contained in the StringUtiles::tokenize_column_descriptor function, but does involve a small change to the kql.g4 grammar to allow the '.' character to be escaped.

For example the key consisting of the tokens {"com.bnn", "uuid"} can now be specified as "com\.bnn.uuid" in KQL.

This PR also adds error handling for invalid KQL key names. Invalid key names currently include keys ending ending in a trailing unescaped '' or '.'.

Validation performed

  • Added unit tests for parsing keys with escaped characters
  • Confirmed that sensible errors are shown on the command line when entering invalid KQL queries

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced error handling in JSON parsing and KQL expression parsing.
    • Added support for escape sequences in column names within KQL.
    • Updated KQL grammar to recognize periods as special characters.
  • Bug Fixes

    • Improved robustness of tokenization methods to prevent failures from propagating.
  • Tests

    • Introduced new test cases for validating the parsing of queries with escaped characters in column names.
    • Added tests for handling illegal escape sequences in column names.

gibber9809 avatar Oct 21 '24 17:10 gibber9809