Skip to main content

parse_path

Function parse_path 

Source
pub(crate) fn parse_path(
    s: &str,
) -> Result<Vec<VariantPathElement<'_>>, ArrowError>
Expand description

Parse a path string into a vector of VariantPathElement.

§Syntax

  • .field or field - access object field (do not support special char)
  • [index] - access array element by index
  • [field] - access object field (support special char with escape \)

§Escape Rules

Inside brackets [...]:

  • \\ -> literal \
  • \] -> literal ]
  • Any other \x -> literal x

Outside brackets, no escaping is supported.

§Examples

  • "" -> empty path
  • "foo" -> single field foo
  • "foo.bar" -> nested fields foo, bar
  • "[1]" -> array index 1
  • "foo[1].bar" -> field foo, index 1, field bar
  • "[a.b]" -> field a.b (dot is literal inside bracket)
  • "[a\\]b]" -> field a]b (escaped ]
  • etc.

§Errors

  • Leading . (e.g., ".foo")
  • Trailing . (e.g., "foo.")
  • Unclosed ‘[’ (e.g., "foo[1")
  • Unexpected ‘]’ (e.g., "foo]")
  • Trailing ‘`’ inside bracket (treated as unclosed bracket)