77
88// A type is a call expression, the way ClickHouse itself models one: a
99// lowercased name applied to an ordered argument list. Each argument is
10- // another type, an integer or a quoted string, optionally labelled, so
10+ // another type, an integer, a boolean or a quoted string, optionally
11+ // labelled, so
1112// Nullable, Array and LowCardinality are ordinary names and nothing about a
1213// nested type is lost. The shape maps one to one onto a protobuf message
1314// with a oneof for the argument value:
@@ -41,6 +42,7 @@ type typeArg struct {
4142 Label string `json:"label,omitempty"`
4243 Type * typeExpr `json:"type,omitempty"`
4344 Int * int64 `json:"int,omitempty"`
45+ Bool * bool `json:"bool,omitempty"`
4446 String * string `json:"string,omitempty"`
4547}
4648
@@ -58,8 +60,9 @@ func parseType(t string) *typeExpr {
5860 return expr
5961}
6062
61- // parseArg parses one argument: a quoted string, an integer, a labelled
62- // argument (`lat Float64` in a Tuple, `'a' = 1` in an Enum), or a type.
63+ // parseArg parses one argument: a quoted string, an integer, a boolean, a
64+ // labelled argument (`lat Float64` in a Tuple, `'a' = 1` in an Enum), or a
65+ // type.
6366func parseArg (a string ) typeArg {
6467 a = strings .TrimSpace (a )
6568 if strings .HasPrefix (a , "'" ) {
@@ -75,6 +78,11 @@ func parseArg(a string) typeArg {
7578 if n , err := strconv .ParseInt (a , 10 , 64 ); err == nil {
7679 return typeArg {Int : & n }
7780 }
81+ switch strings .ToLower (a ) {
82+ case "true" , "false" :
83+ b := strings .EqualFold (a , "true" )
84+ return typeArg {Bool : & b }
85+ }
7886 if i := labelEnd (a ); i > 0 {
7987 arg := parseArg (a [i + 1 :])
8088 arg .Label = a [:i ]
0 commit comments