Replies: 6 comments 2 replies
-
Here is a proposal which @thejumpman2323 and @blythed came up with: import typing as t
import dataclasses as dc
from abc import ABC, abstractmethod
callbacks = {
'insert_many': [
lambda: ...,
],
}
@dc.dataclass
class Collection:
name: str
def __getattr__(self, k):
return Query(self, query_type=k, members=[k])
@dc.dataclass
class Query(ABC):
collection: Collection
query_type: str
members: t.List[str]
args: t.Optional[t.List] = None
kwargs: t.Optional[t.Dict] = None
is_callable: t.Optional[bool] = None
def __getattr__(self, k):
return Query(self, query_type=k, members=[*self.members, k])
def __call__(self, *args, **kwargs):
return Query(
collection=self.collection,
query_type=self.query_type,
members=self.members,
args=args,
kwargs=kwargs
)
@abstractmethod
def execute(self, db):
pass
@db.dataclass
class MongoQuery(Query):
def execute(db):
if len(self.members) == 1:
for f in self.pre_callbacks:
... # TBD
out = getattr(db[self.collection], self.members[0])(*self.args, **self.kwargs)
for f in self.post_callbacks:
f()
return out
else:
parent = ...
return getattr(parent, self.members[-1])(*self.args, **self.kwargs)
@db.dataclass
class IbisQuery(Query):
def __eq__(self, other):
...
def execute(db):
# Main difficulty is distinguishing between do we have a callable member or
# do we have an attribute member
# E.g. ``employees.filter(employees.department == 'HR').aggregate(avg_age=employees.age.mean())``
# Here ``employees.department == 'PR'`` is (table, attribute, comparison)
# Here ``employees.age.mean()`` is (table, attribute, callable)
if len(self.members) == 1:
for f in self.pre_callbacks:
... # TBD
if self.is_callable:
out = getattr(db[self.table], self.members[0])(*self.args, **self.kwargs)
else:
return getattr(self.linked_members[-2], self.members[-1])
for f in self.post_callbacks:
f()
return out |
Beta Was this translation helpful? Give feedback.
-
Discussion of outputs in tabular databasesSituations
Want to extend model to include all of the above. Questions:
|
Beta Was this translation helpful? Give feedback.
-
We should probably have separate classes for SQL/Tabular and NoSQL databases. so for SQL we can have a generalised class with IBIS and for mongodb we can have a generalised class MongoQuery |
Beta Was this translation helpful? Give feedback.
-
The goal for ibis is to be able to "trace" or serialize an IBIS query of the form: table.filter(table.brand == 'Nike')
table.like({'x': torch.randn(10)}).filter(table.brand == 'Nike')
table.filter(table.brand == 'Nike').like({'x': torch.randn(10)})
table['brand', 'id'].filter(...).like(...)
table['brand', 'id'].like(...).filter(...)
table.insert(data) Limited support (but not for table....aggregate() Important methods to implement: query.select_ids
query.select_from_ids
... |
Beta Was this translation helpful? Give feedback.
-
For vector search, the basic algorithm will be:
|
Beta Was this translation helpful? Give feedback.
-
In order to make our claim that we serve datastores credible, we should work out and implement a few other datastore solutions.
Currently the foreseen interfaces/ abstract base classes for doing this are:
db.base.databackend.DataBackend
db.base.artifact_store.ArtifactStore
db.base.metadata.MetaDatastore
db.base.query.*
Currently the
ArtifactStore
andMetaDatastore
are reasonably clean and separated. The primary focus then needs to be on:db.base.databackend.DataBackend
db.base.query.*
The things which we need to be able to do are the following:
Prediction
Reading
Updating/ Writing
id
Fitting/ Training/ Learning
Reading
Querying
Beta Was this translation helpful? Give feedback.
All reactions