MXS-2106: Fix NULL value handling

The NULL values were not stored as NULL Avro values due to the fact that
the file format has no native NULL-ness for the basic types. To solve
this, all values must be stored as a union that contains the actual type
as well as the null type.

Unions were not implemented in the maxavro library but implementing means
simply recursing one level down.
This commit is contained in:
Markus Mäkelä
2018-10-31 21:50:30 +02:00
parent 7f36ec83da
commit 562c7be8fe
6 changed files with 43 additions and 21 deletions

View File

@ -130,9 +130,9 @@ char* json_new_schema_from_table(TABLE_MAP *map)
ss_info_dassert(create->column_types[i] && *create->column_types[i],
"Column type should not be empty or NULL");
json_array_append_new(array, json_pack_ex(&err, 0, "{s:s, s:s, s:s, s:i}",
json_array_append_new(array, json_pack_ex(&err, 0, "{s:s, s:[s, s], s:s, s:i}",
"name", create->column_names[i],
"type", column_type_to_avro_type(map->column_types[i]),
"type", "null", column_type_to_avro_type(map->column_types[i]),
"real_type", create->column_types[i],
"length", create->column_lengths[i]));
}