Error when a schema has defaults array values
HejVkt opened this issue · 1 comments
HejVkt commented
local avro = require('avro_schema')
local yaml = require('yaml')
local schema = {
type = "record",
name = "example",
fields = {
{name = "id", type="string", default=""},
{
name = "simple_array",
type = {
type = "array",
items = "string",
},
default = { "name1","name2" }
},
}
}
local _, created = avro.create(schema)
local _, test_data = avro.validate(created, { id = 'testme'})
print(yaml.encode(test_data))
Output:
tarantool_1 | simple_array:
tarantool_1 | - name1
tarantool_1 | - name2
tarantool_1 | id: testme
tarantool_1 | ...
local ok, methods_test = avro.compile(created)
if ok ~= true then
print(yaml.encode(methods_test))
end
Output:
tarantool_1 | --- '/.rocks/share/tarantool/avro_schema/compiler.lua:141: NYI: default value too complex'
Question is, How сan I set default array values?
mejedi commented
The feature is not implemented, see https://github.com/tarantool/avro-schema/blob/master/avro_schema/compiler.lua#L223
Should be straight-forward to implement, I had this use case in mind when implementing the first version. The idea was to serialise default to binary at compilation time and take advantage of CopyCommand