Expand description
Helper utilities for SQL processing
This module provides various utility functions used throughout the codebase:
- Safe sequence access
- Collection normalization
- String manipulation
- Fixed-point transformation
- Topological sorting
Based on the Python implementation in sqlglot/helper.py.
Structs§
- Single
Valued Mapping - A mapping where all keys return the same value.
Enums§
- Tsort
Error - Error type for topological sort
Constants§
- DATE_
UNITS - Interval units that operate on date components
Traits§
- Ensure
List - Ensures that a value is wrapped in a Vec if it isn’t already a collection.
Functions§
- apply_
index_ offset - Applies an offset to a given integer literal expression for array indexing.
- camel_
to_ snake_ case - Converts a camelCase string to UPPER_SNAKE_CASE
- csv
- Formats any number of string arguments as CSV.
- csv_
default - Formats strings as CSV with default separator “, “
- dict_
depth - Get the nesting depth of a nested HashMap
- ensure_
list - Wrap a single value in a Vec
- ensure_
list_ option - Wrap an Option in a Vec (empty if None)
- find_
new_ name - Searches for a new name that doesn’t conflict with taken names.
- first
- Returns the first element from an iterator
- flatten
- Flattens a nested collection into a flat iterator
- is_
date_ unit - Check if a unit is a date unit (operates on date components)
- is_
float - Check if a string can be parsed as a float
- is_int
- Check if a string can be parsed as an integer
- is_
iso_ date - Check if a string is a valid ISO date (YYYY-MM-DD)
- is_
iso_ datetime - Check if a string is a valid ISO datetime
- merge_
ranges - Merge overlapping ranges
- name_
sequence - Creates a name generator that produces sequential names.
- seq_get
- Returns the value in
seqat positionindex, orNoneifindexis out of bounds. - snake_
to_ camel_ case - Converts a snake_case string to CamelCase
- split_
num_ words - Perform a split on a value and return N words with
Nonefor missing parts. - to_bool
- Convert a boolean-like string to an actual boolean.
- tsort
- Sorts a directed acyclic graph in topological order.
- while_
changing - Applies a transformation to a given expression until a fix point is reached.
- while_
changing_ hash - Applies a transformation until a fix point, using a hash function for comparison.