Skip to content
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

Prototype of Firestore query explain functionality #14079

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jskeet
Copy link
Collaborator

@jskeet jskeet commented Jan 10, 2025

DO NOT MERGE

This is just to demonstrate initial prototyping. Things that need fixing:

  • Rename QueryProfileInfo, probably to ExplainResults to match feat: Query Profiling java-firestore#1609
  • Create new wrapper types for the various outputs (plan summary and explain metrics).
  • Possibly create a new wrapper type for ExplainOptions, and expose a single new method accepting that instead of two new methods that vary by name.

DO NOT MERGE

This is just to demonstrate initial prototyping. Things that need
fixing:

- Rename QueryProfileInfo, probably to ExplainResults to match
  googleapis/java-firestore#1609
- Create new wrapper types for the various outputs (plan summary
  and explain metrics).
- Possibly create a new wrapper type for ExplainOptions, and expose
  a single new method accepting that instead of two new methods that
  vary by name.
@jskeet jskeet added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jan 10, 2025
Copy link
Contributor

@amanda-tarafa amanda-tarafa left a comment

Choose a reason for hiding this comment

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

Yep, this looks good.

+1 On Exposing or wrapping ExplainOptions and having a single Explain method that takes those options.

I'd even consider a SnapshotOptions that contains ExplainOptions and have Snapshot overloads that take the SnapshotOptions and return an "AugmentedSnapshot". That'd make us fully future proof. But, it could get complex, specially the return type AugmentedSnapshot.

@@ -3,59 +3,65 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why this changed? Maybe because of the 1PP work?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes - VS has basically been inconsistent for a while, but now we're generating the sln files ourselves, so we'll definitely end up with FAE04EC0-301F-11D3-BF4B-00C04F79EFBC.

}, cancellationToken).ConfigureAwait(false);

GaxPreconditions.CheckState(readTime != null, "The stream returned from RunQuery did not provide a read timestamp.");
GaxPreconditions.CheckState(readTime is not null || explainOptions?.Analyze == false, "The stream returned from RunQuery did not provide a read timestamp.");
Copy link
Contributor

Choose a reason for hiding this comment

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

So Analyze == false is like a dry run?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, exactly.

var plan = queryProfileInfo.Plan;
var stats = queryProfileInfo.Stats;
Assert.NotNull(plan);
Assert.NotNull(stats);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Assert.NotNull(stats);
Assert.NotNull(stats);
Assert.NotNull(snapshot.ReadTime)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge Indicates a pull request not ready for merge, due to either quality or timing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants