Skip to content

Implement V3Event API (EventCollectionDate) with Spanner backend#1810

Merged
keyurva merged 11 commits intodatacommonsorg:masterfrom
keyurva:event-collection-date
Mar 13, 2026
Merged

Implement V3Event API (EventCollectionDate) with Spanner backend#1810
keyurva merged 11 commits intodatacommonsorg:masterfrom
keyurva:event-collection-date

Conversation

@keyurva
Copy link
Contributor

@keyurva keyurva commented Mar 13, 2026

  • Key Changes: Added a new GQL statement and implemented the query builder logic to fetch event date information from Spanner.
  • The queries are currently slow. Working with the spanner team separately to address this.
    • Incorporated force_join_order hint suggested by the spanner team.
    • Queries while still being slow are much faster than without it.
  • Tested v2/event on prod and the new v3/event endpoint locally for the request node=country/LBR&property=<-location{typeOf:FireEvent}->date and the responses were the same.
    • Responses for country/USA were different. Will follow-up separately with Natalie if its a data issue or if we need to update the query.
  • Wired up the new API through all the necessary server layers (datasources, dispatcher, handler), and registered the new request type for caching.
  • NEXT:
    • Fix issue with country/USA
    • Add support for EventCollection requests
    • Continue perf discussions with the spanner team

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new V3Event API endpoint focused on retrieving event collection dates. It establishes a robust data flow from the API request through the dispatcher and datasource layers, leveraging a Spanner backend for efficient data retrieval. The changes also include necessary updates to the protobuf and gRPC infrastructure, ensuring the new API is fully integrated and performant.

Highlights

  • New V3Event API: Implemented a new V3Event API endpoint specifically designed to handle EventCollectionDate requests, enabling retrieval of event date information.
  • Spanner Backend Integration: Integrated the new V3Event API with a Spanner backend, including a new GQL statement and query builder logic to fetch event dates efficiently.
  • API Layer Wiring: Wired up the new V3Event API across various server layers, including datasources, dispatcher, and handler, ensuring end-to-end functionality.
  • Caching Support: Registered the new V3Event request type for caching, which will improve performance for repeated queries.
  • Multi-Event Merging Utility: Added a new utility function, MergeMultiEvent, to merge multiple V2 EventResponses, which is crucial for aggregating data from various sources.
  • Protobuf and gRPC Updates: Updated protobuf and gRPC generated code to reflect the new API endpoint and ensure compatibility with newer versions of protoc-gen-go and protoc-gen-go-grpc.
Changelog
  • internal/merger/merger.go
    • Added MergeMultiEvent function to merge multiple V2 EventResponses.
  • internal/merger/merger_test.go
    • Added test cases for the new MergeMultiEvent function, covering empty, single, and multiple input scenarios with date and event merging.
  • internal/proto/service/mixer.pb.go
    • Updated protoc-gen-go version from v1.30.0 to v1.36.11.
    • Added unsafe import.
    • Modified file_service_mixer_proto_rawDesc to use unsafe.Slice and unsafe.StringData for raw descriptor handling.
  • internal/proto/service/mixer_grpc.pb.go
    • Updated protoc-gen-go-grpc version from v1.3.0 to v1.6.0.
    • Updated grpc.SupportPackageIsVersion from 7 to 9.
    • Added Mixer_V3Event_FullMethodName constant.
    • Added V3Event method to the MixerClient interface.
    • Added V3Event method to the MixerServer interface.
    • Implemented V3Event client method with grpc.StaticMethod() option.
    • Added V3Event method to UnimplementedMixerServer.
    • Added testEmbeddedByValue method to UnimplementedMixerServer for embedding check.
    • Added _Mixer_V3Event_Handler function.
    • Registered V3Event handler in Mixer_ServiceDesc.
  • internal/server/datasource/datasource.go
    • Added Event method to the DataSource interface.
  • internal/server/datasources/datasources.go
    • Implemented the Event method, utilizing fetchAndMerge with merger.MergeMultiEvent for processing V2 EventRequests.
  • internal/server/dispatcher/dispatcher.go
    • Added TypeEvent to the RequestType enum.
    • Implemented the Event method to dispatch V2 EventRequests through the datasource layer.
  • internal/server/handler_v3.go
    • Implemented the V3Event handler, calling the dispatcher's Event method.
  • internal/server/redis/processor.go
    • Added dispatcher.TypeEvent to newEmptyResponse to support caching for V2 EventResponses.
  • internal/server/remote/client.go
    • Added Event method to RemoteClient to fetch V2 EventResponses from a remote endpoint.
  • internal/server/remote/datasource.go
    • Implemented the Event method for RemoteDataSource, delegating to the remote client.
  • internal/server/spanner/client.go
    • Added GetEventCollectionDate method to the SpannerClient interface.
  • internal/server/spanner/datasource.go
    • Imported pbv1 for EventCollectionDate.
    • Added eventCollectionDateRequest struct for parsing event requests.
    • Implemented the Event method to handle V2 EventRequests, parsing properties and delegating to specific handlers.
    • Added parseEventCollectionDate function to extract place ID and event type from event properties.
    • Added handleEventCollectionDate function to query Spanner for event collection dates and construct the response.
  • internal/server/spanner/golden/datasource/event_collection_date_lbr.json
    • Added golden JSON file for EventCollectionDate datasource test results for 'country/LBR' and 'FireEvent'.
  • internal/server/spanner/golden/datasource_test.go
    • Added TestSpannerEvent to test the Spanner datasource's Event method against golden files.
  • internal/server/spanner/golden/query/get_event_collection_date.json
    • Added golden JSON file for GetEventCollectionDate query results.
  • internal/server/spanner/golden/query_builder/get_event_collection_date.sql
    • Added golden SQL query for GetEventCollectionDate.
  • internal/server/spanner/golden/query_builder_test.go
    • Added TestGetEventCollectionDateQuery to test the Spanner query builder for event collection dates.
  • internal/server/spanner/golden/query_cases_test.go
    • Added eventCollectionDateTestCases for testing event collection date queries.
  • internal/server/spanner/golden/query_test.go
    • Added TestGetEventCollectionDate to test the Spanner client's GetEventCollectionDate method against golden files.
  • internal/server/spanner/query.go
    • Implemented GetEventCollectionDate method to retrieve event collection dates from Spanner using a dynamic query.
  • internal/server/spanner/query_builder.go
    • Added GetEventCollectionDateQuery function to construct a Spanner statement for fetching event collection dates.
  • internal/server/spanner/statements.go
    • Added getEventCollectionDate string constant containing the SQL query for fetching event collection dates.
  • internal/sqldb/datasource.go
    • Added a no-op Event method to SQLDataSource for forward compatibility.
  • proto/service/mixer.proto
    • Added V3Event RPC definition to the Mixer service, including HTTP GET and POST bindings.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully implements the V3Event API, specifically for EventCollectionDate requests, with a Spanner backend. The changes are well-structured, spanning from the protobuf definitions to the data source implementations. New query logic for Spanner is introduced, accompanied by thorough tests and golden files. The necessary wiring through the dispatcher, handler, and caching layers is also correctly handled. I have one suggestion for the remote client implementation to maintain consistency with repository guidelines.

@keyurva keyurva force-pushed the event-collection-date branch from 89787e5 to 856e8ee Compare March 13, 2026 17:33
@keyurva keyurva requested a review from n-h-diaz March 13, 2026 17:39
Copy link
Contributor

@juliawu juliawu left a comment

Choose a reason for hiding this comment

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

Thank you for hooking this up, and adding tests!

Comment on lines +298 to +301
RETURN DISTINCT
SUBSTR(dateNode.value, 1, 7) AS month
ORDER BY
month`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you tell me a bit more about why "month" is the right time resolution to use here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After chatting with Natalie, it seems that month is the finest level of granularity we support for events:

// - The format of 'date' is YYYY-MM.

Copy link
Contributor Author

@keyurva keyurva left a comment

Choose a reason for hiding this comment

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

Thanks for the review!

Comment on lines +298 to +301
RETURN DISTINCT
SUBSTR(dateNode.value, 1, 7) AS month
ORDER BY
month`,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

After chatting with Natalie, it seems that month is the finest level of granularity we support for events:

// - The format of 'date' is YYYY-MM.

@keyurva keyurva added this pull request to the merge queue Mar 13, 2026
@keyurva keyurva removed this pull request from the merge queue due to a manual request Mar 13, 2026
@keyurva keyurva added this pull request to the merge queue Mar 13, 2026
Merged via the queue into datacommonsorg:master with commit 1cc7a2d Mar 13, 2026
4 of 5 checks passed
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.

2 participants