-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support in-memory datasets #1743
base: main
Are you sure you want to change the base?
Conversation
1538a81
to
32753d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we try to reduce the number of API changes here?
@@ -467,28 +468,29 @@ impl Dataset { | |||
/// Returns the newly created [`Dataset`]. | |||
/// Or Returns [Error] if the dataset already exists. | |||
/// | |||
pub async fn write( | |||
pub async fn write_to_uri( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did we have to rename this? It seems like it really blew up the scope of the PR and is still causing CI failures.
pub async fn overwrite( | ||
&mut self, | ||
batches: impl RecordBatchReader + Send + 'static, | ||
params: Option<WriteParams>, | ||
) -> Result<()> { | ||
// Box it so we don't monomorphize for every one. We take the generic | ||
// parameter for API ergonomics. | ||
let batches = Box::new(batches); | ||
let params = params.unwrap_or_else(|| WriteParams { | ||
mode: WriteMode::Overwrite, | ||
..Default::default() | ||
}); | ||
self.write_impl(batches, params).await | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this does more than just overwrite if the user passes WriteParams
with mode
other than WriteMode::Overwrite
, so perhaps this is not a great name? Could do something like write_into()
.
self, | ||
data_obj: ReaderLike, | ||
schema: Optional[Schema] = None, | ||
mode: str = "append", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can get much better auto-complete if you use Literal
.
mode: str = "append", | |
mode: Literal["append", "overwrite"] = "append", |
def __init__(self, _ds: _Dataset): | ||
self._uri = _ds.uri | ||
self._ds = _ds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to break so much existing code...
Could we instead just make a classmethod and keep the existing init method:
@classmethod
def _from_inner(cls, ds: _Dataset):
self = cls.__new__()
self._uri = _ds.uri
self._ds = _ds
return self
To support in-memory LanceDB tables, we want to be able to keep a reference to the same object store across various dataset operations. This required the following changes:
write_data
towrite_to_uri
to disambiguate from thewrite_data
instance methods