Closed libbey-observable closed 1 year ago
Regarding the check for "Could not convert", if it's not complicated I'd rather have it, not so much for performance but to clarify the code path.
I agree, and added a check for "Could not convert." It does feel a bit brittle to add a check for a hard-coded string, but the clarity it adds seems worth it.
@mbostock It's much simpler now, no need for any config/options anywhere. Thanks for your feedback!
Partially resolves https://github.com/observablehq/observablehq/issues/9857
The two cases it resolves are:
Case 2 (and likely case 1) occurred when the mismatch was found in a row > 10240, as that's the (default?) sample size DuckDB checks when inferring types.
Now, if
insertCSVFromPath
fails, we catch it, check whether it failed due to a conversion error, and if so, try again with all columns as strings. Only CSV and TSV files are affected by this change.The error for case 1 (before): Case 1 fixed (after):
Video showing before and after for case 2:
https://user-images.githubusercontent.com/111310561/211949879-3281b4bf-047a-4866-a65c-358e1814eb44.mov