-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Map crashes when it produces a null entry in the record #1492
Comments
@jsternberg Question of clarification: Is this caused when type inference determines that the property of the record is always null, i.e. the entire column is going to be null? Or is it that a single record produced a null value? |
This is when the entire column is going to be null. The transpiler may have access a column incorrectly which is what caused this to be exercised. I'll construct a test that creates the error first. |
My proposal to fix this is that if the type is null, we do not add it as a column since that's the only way it can be represented. If it is anything else, I add some error handling for when an invalid type is present. |
I think that it could happen also if the first value of a new column is null. m, err := t.fn.Eval(i, cr)
if err != nil {
return errors.Wrap(err, "failed to evaluate map function")
}
if i == 0 {
properties = m.Type().Properties()
keys = make([]string, 0, len(properties))
for k := range properties {
keys = append(keys, k)
}
sort.Strings(keys)
// Determine on which cols to group
on = make(map[string]bool, len(tbl.Key().Cols()))
for _, c := range tbl.Key().Cols() {
on[c.Label] = t.mergeKey || execute.ContainsStr(keys, c.Label)
}
}
key := groupKeyForObject(i, cr, m, on)
builder, created := t.cache.TableBuilder(key)
if created {
if t.mergeKey {
if err := execute.AddTableKeyCols(tbl.Key(), builder); err != nil {
return err
}
}
// Add columns from function in sorted order
for _, k := range keys {
if t.mergeKey && tbl.Key().HasCol(k) {
continue
}
if _, err := builder.AddCol(flux.ColMeta{
Label: k,
Type: execute.ConvertFromKind(properties[k].Nature()),
}); err != nil {
return err
}
}
} I think that is enough that |
Not adding the column should have the same behavior of adding a column with every value as null as far as reading values goes. But a missing column will likely cause issues when we explicitly check the schema of tables. Do we need the ability to represent a |
@affo you make a good point there. It's weird, but it seems like map isn't using type inference to determine the column types. So that's another part of the bug. It should be using the results of type inference. I think that changes the bug. Type inference may have worked correctly, but one of the values is null. |
Isn't this because we couldn't get type inference to work using |
I put up test cases that demonstrate the error in #1494. I'll start seeing if I can fix it and whether |
I took a look and I'll have a workaround for that. Type inference should be used, but we'll just workaround it for now. |
If
map
is used and the returned record has a null value, this causes a crash because a null column cannot be represented in the record itself.The text was updated successfully, but these errors were encountered: