You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I currently have a small helper package that supports SQLite Vec functions, and I would like to add support for vec_each which is a table function in SQLite Vec.
Another discussion a couple months ago brought up json_each which is also in the same boat, though the discussion didn't really propose the kind of general solution that I think would be ideal.
In particular, the limiting factor seems to stem from the fact that the Table protocol is quite static in nature, and can't have it's tableFragment altered dynamically since it's a static requirement which prevents any sort of dynamic value to be bound.
As a result, creating this statement from Swift.
SELECT*FROM vec_each(<some vector here>);
Without resorting to escaping via #sql isn't really possible.
Ideally, a general solution here would be non-static and also be able to be usable for similar concepts in other SQL dialects (eg. Table Value Functions in SQL Server). Something like:
@Table@SelectionpublicstructVecEachRow{publicletrowId:Intpublicletvalue:Float
// ...
}publicstructVecEachExpression:TableFragmentExpression{publictypealiasQueryValue=VecEachRowpublicletvector:[Float]publicvartableFragment:QueryFragment{"vec_each(\(vector))"}}publicfunc vecEach(_ vector:[Float])->VecEachExpression{
// ...
}
// Would need dedicated overloads on TableFragmentSelection to support all the select syntax that `Table` gets.
letquery=vecEach(vector).all
.where{ /* ... */ }.select{ /* ... */ }
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I currently have a small helper package that supports SQLite Vec functions, and I would like to add support for
vec_eachwhich is a table function in SQLite Vec.Another discussion a couple months ago brought up
json_eachwhich is also in the same boat, though the discussion didn't really propose the kind of general solution that I think would be ideal.In particular, the limiting factor seems to stem from the fact that the
Tableprotocol is quite static in nature, and can't have it'stableFragmentaltered dynamically since it's a static requirement which prevents any sort of dynamic value to be bound.As a result, creating this statement from Swift.
Without resorting to escaping via
#sqlisn't really possible.Ideally, a general solution here would be non-static and also be able to be usable for similar concepts in other SQL dialects (eg. Table Value Functions in SQL Server). Something like:
Then for
vec_each:Beta Was this translation helpful? Give feedback.
All reactions