Skip to content

Allow updating multiple view representations#15

Closed
SergeiPatiakin wants to merge 19 commits intomainfrom
upsert-representation-2
Closed

Allow updating multiple view representations#15
SergeiPatiakin wants to merge 19 commits intomainfrom
upsert-representation-2

Conversation

@SergeiPatiakin
Copy link
Copy Markdown

@SergeiPatiakin SergeiPatiakin commented May 22, 2025

  • Changed Operation::UpdateRepresentation to Operation::UpdateRepresentations which can take multiple representations
  • Operation::UpdateRepresentations preserves representations in other dialects instead of overwriting them
  • View default_catalog property is not set if catalog name is an empty string

@SergeiPatiakin SergeiPatiakin force-pushed the upsert-representation-2 branch from 805e3a3 to 7b373db Compare May 22, 2025 10:05
@SergeiPatiakin SergeiPatiakin changed the title Upsert multiple view representations Allow updating multiple view representations May 22, 2025
@SergeiPatiakin SergeiPatiakin marked this pull request as ready for review May 22, 2025 10:14
@SergeiPatiakin SergeiPatiakin requested a review from mildbyte May 22, 2025 10:15
version.default_namespace = namespace.to_vec()
}
if version.default_catalog().is_none() {
if version.default_catalog().is_none() && !catalog.name().is_empty() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code (whole if let some(version)) is repeating with the one on line 220 and could be moved to a separate function.

Comment on lines +72 to +74
for r in new_representations {
representations = upsert_representation(&representations, r.clone());
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really dislike such naming. For such a small code block is easy to see what it is, but if for-block grows, it becomes annoying to figure it out what the single letter variable is.

The mut avoids cloning and rebuilding representations for each new representation.

Suggested change
for r in new_representations {
representations = upsert_representation(&representations, r.clone());
}
for representation in new_representations {
representations = upsert_representation(&mut representations, representation.clone());
}

Comment on lines +39 to +42
fn upsert_representation(
current_representations: &[ViewRepresentation],
new_representation: ViewRepresentation,
) -> Vec<ViewRepresentation> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function allocates a new Vec every time it’s called, and you call it in a loop on line 73. If new_representations contains N elements and current_representations contains M, this results in O(N * M) copies and allocations.

Suggested change
fn upsert_representation(
current_representations: &[ViewRepresentation],
new_representation: ViewRepresentation,
) -> Vec<ViewRepresentation> {
fn upsert_representation(
representations: &mut Vec<ViewRepresentation>,
new_representation: ViewRepresentation,
) -> Vec<ViewRepresentation> {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but I don't expect the number of representations to ever exceed single digits. There's not that many different analytics systems with incompatible representations.

@SergeiPatiakin
Copy link
Copy Markdown
Author

Closing because merged upstream: JanKaul#181

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants