-
Notifications
You must be signed in to change notification settings - Fork 538
Introduce the dataset manifest and remove layer information from the partition table #11423
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
Draft
abey79
wants to merge
16
commits into
main
Choose a base branch
from
antoine/layer-table
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+684
−90
Draft
Changes from 7 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6850986
Add grpc endpoint for layer table and cleanup helper objects
abey79 1cd8a69
add table provider for layer table
abey79 1ce0fc5
add `DatasetEntry.layer_table` to Python SDK
abey79 33f7409
reintroduce storage_urls in partition table
abey79 abc37b0
Fix schema mismatch
abey79 feb1b31
Rename everything to "DatasetManifest"
abey79 b070cbe
Fix name + update proto docstring
abey79 5d43d14
Apply suggestion from @Copilot
abey79 6bba8ab
Apply suggestion from @Copilot
abey79 a82dbb4
Minor fix
abey79 fcd9b23
Merge branch 'main' into antoine/layer-table
abey79 648d46a
Minor minor fix
abey79 af5c3df
Add explicit `fields()` method
abey79 8778501
Add explicit `xxx_inner_field()` methods
abey79 3e5baa0
Remove utterly deprecated constants
abey79 ff20d4e
More docstring and rename to `LAYER_NAMES`
abey79 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
use std::sync::Arc; | ||
|
||
use arrow::{array::RecordBatch, datatypes::SchemaRef}; | ||
use async_trait::async_trait; | ||
use datafusion::{ | ||
catalog::TableProvider, | ||
error::{DataFusionError, Result as DataFusionResult}, | ||
}; | ||
use tracing::instrument; | ||
|
||
use re_log_encoding::codec::wire::decoder::Decode as _; | ||
use re_log_types::EntryId; | ||
use re_protos::{ | ||
cloud::v1alpha1::{ScanDatasetManifestRequest, ScanDatasetManifestResponse}, | ||
headers::RerunHeadersInjectorExt as _, | ||
}; | ||
use re_redap_client::ConnectionClient; | ||
|
||
use crate::grpc_streaming_provider::{GrpcStreamProvider, GrpcStreamToTable}; | ||
use crate::wasm_compat::make_future_send; | ||
|
||
//TODO(ab): deduplicate from PartitionTableProvider | ||
#[derive(Clone)] | ||
pub struct DatasetManifestProvider { | ||
client: ConnectionClient, | ||
dataset_id: EntryId, | ||
} | ||
|
||
impl std::fmt::Debug for DatasetManifestProvider { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
f.debug_struct("DatasetManifestProvider") | ||
.field("dataset_id", &self.dataset_id) | ||
.finish() | ||
} | ||
} | ||
|
||
impl DatasetManifestProvider { | ||
pub fn new(client: ConnectionClient, dataset_id: EntryId) -> Self { | ||
Self { client, dataset_id } | ||
} | ||
|
||
/// This is a convenience function | ||
pub async fn into_provider(self) -> DataFusionResult<Arc<dyn TableProvider>> { | ||
Ok(GrpcStreamProvider::prepare(self).await?) | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl GrpcStreamToTable for DatasetManifestProvider { | ||
type GrpcStreamData = ScanDatasetManifestResponse; | ||
|
||
#[instrument(skip(self), err)] | ||
async fn fetch_schema(&mut self) -> DataFusionResult<SchemaRef> { | ||
let mut client = self.client.clone(); | ||
|
||
let dataset_id = self.dataset_id; | ||
|
||
Ok(Arc::new( | ||
make_future_send(async move { | ||
client | ||
.get_dataset_manifest_schema(dataset_id) | ||
.await | ||
.map_err(|err| { | ||
DataFusionError::External( | ||
format!("Couldn't get partition table schema: {err}").into(), | ||
) | ||
}) | ||
}) | ||
.await?, | ||
)) | ||
} | ||
|
||
// TODO(ab): what `GrpcStreamToTable` attempts to simplify should probably be handled by | ||
// `ConnectionClient` | ||
#[instrument(skip(self), err)] | ||
async fn send_streaming_request( | ||
&mut self, | ||
) -> DataFusionResult<tonic::Response<tonic::Streaming<Self::GrpcStreamData>>> { | ||
let request = tonic::Request::new(ScanDatasetManifestRequest { | ||
columns: vec![], // all of them | ||
}) | ||
.with_entry_id(self.dataset_id) | ||
.map_err(|err| DataFusionError::External(Box::new(err)))?; | ||
|
||
let mut client = self.client.clone(); | ||
|
||
make_future_send(async move { Ok(client.inner().scan_dataset_manifest(request).await) }) | ||
.await? | ||
.map_err(|err| DataFusionError::External(Box::new(err))) | ||
} | ||
|
||
fn process_response( | ||
&mut self, | ||
response: Self::GrpcStreamData, | ||
) -> DataFusionResult<RecordBatch> { | ||
response | ||
.data | ||
.ok_or(DataFusionError::Execution( | ||
"DataFrame missing from PartitionList response".to_owned(), | ||
abey79 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
))? | ||
.decode() | ||
.map_err(|err| DataFusionError::External(Box::new(err))) | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.