Class: ClickhouseRuby::Types::Parser
- Inherits:
-
Object
- Object
- ClickhouseRuby::Types::Parser
- Defined in:
- lib/clickhouse_ruby/types/parser.rb
Overview
AST-based parser for ClickHouse type strings
This parser correctly handles nested types like:
-
Array(Tuple(String, UInt64))
-
Map(String, Array(Nullable(Int32)))
-
Nullable(LowCardinality(String))
The parser does NOT validate types - it only handles syntax. Type validation is delegated to ClickHouse.
Grammar:
type := simple_type | parameterized_type
parameterized_type := identifier "(" type_list ")"
type_list := type ("," type)*
simple_type := identifier
identifier := [a-zA-Z_][a-zA-Z0-9_]*
Defined Under Namespace
Classes: ParseError
Instance Method Summary collapse
-
#parse(type_string) ⇒ Hash
Parses a ClickHouse type string into an AST.
Instance Method Details
#parse(type_string) ⇒ Hash
Parses a ClickHouse type string into an AST
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/clickhouse_ruby/types/parser.rb', line 60 def parse(type_string) raise ParseError.new('Type string cannot be nil') if type_string.nil? @input = type_string.strip @pos = 0 raise ParseError.new('Type string cannot be empty', input: type_string) if @input.empty? result = parse_type skip_whitespace # Ensure we consumed the entire input unless @pos >= @input.length raise ParseError.new("Unexpected character '#{@input[@pos]}'", position: @pos, input: type_string) end result end |