This PR adds a getSchema function, building on a suggestion from Mike. This function conditionally infers a schema depending on whether or not a valid one exists on the source, combines the schema with any saved type assertions, and determines whether or not the source data needs to be coerced.
We will use getSchema in both __table and in the table schema tasks in the worker (I'll update https://github.com/observablehq/observablehq/pull/11496 to use this function), and thereby unify the two paths that we currently have for type inference.
I also added a missing unit test for type assertion in __table, as well as some tests for getSchema.
hm on second thought, maybe we should handle type assertions outside of getSchema, because it's a pain to have to pass around operations.types in the worker.
This PR adds a
getSchema
function, building on a suggestion from Mike. This function conditionally infers a schema depending on whether or not a valid one exists on the source, combines the schema with any saved type assertions, and determines whether or not the source data needs to be coerced.We will use
getSchema
in both__table
and in the table schema tasks in the worker (I'll update https://github.com/observablehq/observablehq/pull/11496 to use this function), and thereby unify the two paths that we currently have for type inference.I also added a missing unit test for type assertion in
__table
, as well as some tests forgetSchema
.