Is your feature request related to a problem?
At the moment, the add_row and add_rows methods of Table raise an exception if the schemata of the current Table and the new Row differ:
if self._schema != row.schema:
raise SchemaMismatchError()
This is a particular problem, if the Table is empty.
Desired solution
- If the schema of the
Table is empty (no columns), accept any Row and use the schema of the Row as the schema of the new Table
- Otherwise, verify that the list of column names is the same for the
Table and the Row. Don't fail if the types differ, but instead widen them so all values in the Table and the values in the Row are included. For each column, the resulting type should be the lowest common supertype of the type of the column in the Table and the Row
Example:
- Schema of resulting
Table:
{
"a": RealNumber() # Common supertype of `Integer()` and `RealNumber()`
}
Type hierarchy:
- Anything
- RealNumber
- Boolean
- String
Nullability of one of the types gets propagated to the result, i.e. iff any of the types was nullable, the result type is also nullable.
Possible alternatives (optional)
No response
Screenshots (optional)
No response
Additional Context (optional)
No response
Is your feature request related to a problem?
At the moment, the
add_rowandadd_rowsmethods ofTableraise an exception if the schemata of the currentTableand the newRowdiffer:This is a particular problem, if the
Tableis empty.Desired solution
Tableis empty (no columns), accept anyRowand use the schema of theRowas the schema of the newTableTableand theRow. Don't fail if the types differ, but instead widen them so all values in theTableand the values in theRoware included. For each column, the resulting type should be the lowest common supertype of the type of the column in theTableand theRowExample:
Table:{ "a": Integer() }Row:{ "a": RealNumber() }Table:{ "a": RealNumber() # Common supertype of `Integer()` and `RealNumber()` }Type hierarchy:
Nullability of one of the types gets propagated to the result, i.e. iff any of the types was nullable, the result type is also nullable.
Possible alternatives (optional)
No response
Screenshots (optional)
No response
Additional Context (optional)
No response