@@ -420,9 +420,7 @@ defmodule Ch.RowBinary do
420420 _ when is_integer ( value ) -> [ 0x0A | encode ( :i64 , value ) ]
421421 _ when is_float ( value ) -> [ 0x0E | encode ( :f64 , value ) ]
422422 % Date { } -> [ 0x0F | encode ( :date , value ) ]
423- % DateTime { } -> [ 0x11 | encode ( :datetime , value ) ]
424423 % NaiveDateTime { } -> [ 0x11 | encode ( :datetime , value ) ]
425- % { } -> [ 0x30 , 0x00 , 0x80 , 0x08 , 0x20 , 0x00 , 0x00 , 0x00 | encode ( :json , value ) ]
426424 [ ] -> [ 0x1E , 0x00 ]
427425 end
428426 end
@@ -1132,74 +1130,6 @@ defmodule Ch.RowBinary do
11321130 decode_dynamic_continue ( rest , [ :low_cardinality | dynamic ] , types_rest , row , rows , types )
11331131 end
11341132
1135- # JSON(max_dynamic_paths=N, max_dynamic_types=M, path Type, SKIP skip_path, SKIP REGEXP skip_path_regexp) 0x30<uint8_serialization_version><var_int_max_dynamic_paths><uint8_max_dynamic_types><var_uint_number_of_typed_paths><var_uint_path_name_size_1><path_name_data_1><encoded_type_1>...<var_uint_number_of_skip_paths><var_uint_skip_path_size_1><skip_path_data_1>...<var_uint_number_of_skip_path_regexps><var_uint_skip_path_regexp_size_1><skip_path_data_regexp_1>...
1136- defp decode_dynamic ( << 0x30 , rest :: bytes >> , dynamic , types_rest , row , rows , types ) do
1137- # Assert uint8_serialization_version to be 0
1138- << 0x00 , rest :: bytes >> = rest
1139-
1140- # Skip var_int_max_dynamic_paths
1141- { _paths , rest } = read_varint ( rest )
1142-
1143- # Skip uint8_max_dynamic_types
1144- << _val , rest :: bytes >> = rest
1145-
1146- # Read var_uint_number_of_typed_paths
1147- { typed_paths , rest } = read_varint ( rest )
1148-
1149- # Skip `typed_paths` typed paths
1150- rest =
1151- Enum . reduce ( 1 .. typed_paths // 1 , rest , fn _ , rest ->
1152- { count , rest } = read_varint ( rest )
1153- << _discard :: size ( count ) - bytes , rest :: bytes >> = rest
1154- skip_type ( rest )
1155- end )
1156-
1157- # Read var_uint_number_of_skip_paths
1158- { skip_paths , rest } = read_varint ( rest )
1159-
1160- # Skip `skip_paths` skipped paths
1161- rest =
1162- Enum . reduce ( 1 .. skip_paths // 1 , rest , fn _ , rest ->
1163- { count , rest } = read_varint ( rest )
1164- << _discard :: size ( count ) - bytes , rest :: bytes >> = rest
1165- rest
1166- end )
1167-
1168- # Read var_uint_number_of_skip_path_regexps
1169- { skip_path_regexes , rest } = read_varint ( rest )
1170-
1171- # Skip `skip_path_regexes` skipped paths regex
1172- rest =
1173- Enum . reduce ( 1 .. skip_path_regexes // 1 , rest , fn _ , rest ->
1174- { count , rest } = read_varint ( rest )
1175- << _discard :: size ( count ) - bytes , rest :: bytes >> = rest
1176- rest
1177- end )
1178-
1179- decode_dynamic_continue ( rest , [ :json | dynamic ] , types_rest , row , rows , types )
1180- end
1181-
1182- for { pattern , value } <- varints do
1183- defp read_varint ( << unquote ( pattern ) , rest :: bytes >> ) , do: { unquote ( value ) , rest }
1184- end
1185-
1186- other_dynamic_types = [
1187- datetime: 0x11 ,
1188- set: 0x21 ,
1189- bfloat16: 0x31 ,
1190- time: 0x32
1191- ]
1192-
1193- # Consume a type header from binary input, returning the rest.
1194- # TODO: Only supports single-byte type headers for now.
1195- def skip_type ( << type , rest :: bytes >> )
1196- when type in unquote ( Keyword . values ( dynamic_types ++ other_dynamic_types ) ) , do: rest
1197-
1198- def skip_type ( << type , _ :: bytes >> ) do
1199- raise ArgumentError ,
1200- "Unsupported type definition (starting with 0x#{ Base . encode16 ( << type >> ) } ) while decoding dynamic JSON. Only single-byte type identifiers are currently supported."
1201- end
1202-
12031133 # TODO
12041134 # Enum8 0x17 <var_uint_number_of_elements><var_uint_name_size_1><name_data_1><int8_value_1>...<var_uint_name_size_N><name_data_N><int8_value_N>
12051135 # Enum16 0x18 <var_uint_number_of_elements><var_uint_name_size_1><name_data_1><int16_little_endian_value_1>...><var_uint_name_size_N><name_data_N><int16_little_endian_value_N>
@@ -1215,6 +1145,7 @@ defmodule Ch.RowBinary do
12151145 # Custom type (Ring, Polygon, etc) 0x2C<var_uint_type_name_size><type_name_data>
12161146 # SimpleAggregateFunction(function_name(param_1, ..., param_N), arg_T1, ..., arg_TN) 0x2E<var_uint_function_name_size><function_name_data><var_uint_number_of_parameters><param_1>...<param_N><var_uint_number_of_arguments><argument_type_encoding_1>...<argument_type_encoding_N> (see aggregate function parameter binary encoding)
12171147 # Nested(name1 T1, ..., nameN TN) 0x2F<var_uint_number_of_elements><var_uint_name_size_1><name_data_1><nested_type_encoding_1>...<var_uint_name_size_N><name_data_N><nested_type_encoding_N>
1148+ # JSON(max_dynamic_paths=N, max_dynamic_types=M, path Type, SKIP skip_path, SKIP REGEXP skip_path_regexp) 0x30<uint8_serialization_version><var_int_max_dynamic_paths><uint8_max_dynamic_types><var_uint_number_of_typed_paths><var_uint_path_name_size_1><path_name_data_1><encoded_type_1>...<var_uint_number_of_skip_paths><var_uint_skip_path_size_1><skip_path_data_1>...<var_uint_number_of_skip_path_regexps><var_uint_skip_path_regexp_size_1><skip_path_data_regexp_1>...
12181149
12191150 unsupported_dynamic_types = % {
12201151 "Enum8" => 0x17 ,
@@ -1230,7 +1161,8 @@ defmodule Ch.RowBinary do
12301161 "Dynamic" => 0x2B ,
12311162 "CustomType" => 0x2C ,
12321163 "SimpleAggregateFunction" => 0x2E ,
1233- "Nested" => 0x2F
1164+ "Nested" => 0x2F ,
1165+ "JSON" => 0x30
12341166 }
12351167
12361168 for { type , code } <- unsupported_dynamic_types do
0 commit comments