4 ms·
Sqlite does not allow table valued functions to return results with varying schemas. The schema must be defined once up front and then cannot change. That foru
by eatonphil 4y ago
Sqlite does not allow table valued functions to return results with varying schemas. The schema must be defined once up front and then cannot change.
That forum post is a request I made to them to allow dynamic columns but they don't seem interested so far.
- sitkack 4y agoI get that as how it currently stands. But somewhere in the sqlite codebase, everything is a projection. Still thinking and reading through sqlite source ...
- simonw 4y agoI've been contemplating a workaround for this: since registering a new function to a SQLite connection (and deregistering it later) is a pretty fast operation, it should be possible to register a custom function with the detected columns for a single use only and then remove it after running the query.
- eatonphil 4y agoThe problem is if you have multiple function calls within one query. You could give them all a unique name though. Like call "the importX family": import1, import2, import3, etc... Still not ideal but at least possible. Edit: Actually if you just transform the query to add the suffix then that's pretty reasonable a UX. This might give me a way forward to try out TVFs!
- sitkack 4y agoYeah, I was thinking along the same lines, possibly running SQLite under Cling [1] via cppyy [2] [1] https://www.infoq.com/news/2015/05/cling-cpp-interpreter/ https://www.infoq.com/news/2015/05/cling-cpp-interpreter/ [2] https://github.com/wlav/cppyy https://github.com/wlav/cppyy