Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(data-warehouse): add 4 missing tables to the Rocketlane source (#118860)

Tom Owers3aa9e5a742ed
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
index d81d4d065292..687b48ccd348 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
@@ -10270,10 +10270,10 @@ Today (5): `fields`, `projects`, `tasks`, `time_entries`, `users`
Diffed against: <https://developer.rocketlane.com/reference/get-all-projects>
-- [ ] `invoices (search-invoices / get-invoice)` — billing and revenue per project, absent today (high)
-- [ ] `invoices/{id}/line-items (get-invoice-line-items)` — line-item revenue breakdown against projects and tasks (high)
-- [ ] `time-entry-categories (get-time-entry-categories)` — lookup table resolving the category IDs carried on time_entries we already sync (high)
-- [ ] `phases (get-all-phases)` — lookup table resolving the phase IDs on tasks and projects we already sync (high)
+- [x] `invoices (search-invoices / get-invoice)` — billing and revenue per project, absent today (high). Synced as `invoices`.
+- [x] `invoices/{id}/line-items (get-invoice-line-items)` — line-item revenue breakdown against projects and tasks (high). Synced as `invoice_line_items` from `/invoices/{invoiceId}/lines`, one fetch per invoice.
+- [x] `time-entry-categories (get-time-entry-categories)` — lookup table resolving the category IDs carried on time_entries we already sync (high). Synced as `time_entry_categories` from `/time-entries/categories`.
+- [x] `phases (get-all-phases)` — lookup table resolving the phase IDs on tasks and projects we already sync (high). Synced as `phases`, one fetch per project, because `/phases` requires a `projectId` filter.
- [ ] `resource-allocations (get-all-resource-allocations)` — planned capacity to compare against logged time entries (high)
- [ ] `invoices/{id}/payments (get-invoice-payments)` — cash collection and AR aging (medium)
- [ ] `time-offs (get-all-timeoffs)` — needed for correct utilization and availability math (medium)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/rocketlane/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/rocketlane/canonical_descriptions.py
index 81cf2ee653ad..8e7f8585987d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/rocketlane/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/rocketlane/canonical_descriptions.py
@@ -99,4 +99,72 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"updatedAt": "When the field was last modified (epoch milliseconds).",
},
},
+ "invoices": {
+ "description": "A Rocketlane invoice raised against a customer company for one or more projects.",
+ "docs_url": "https://developer.rocketlane.com/reference/search-invoices",
+ "columns": {
+ "invoiceId": "The unique, system-generated identifier of the invoice.",
+ "invoiceNumber": "The invoice number assigned to this invoice.",
+ "dateOfIssue": "The date the invoice was issued (YYYY-MM-DD).",
+ "dueDate": "The due date for the invoice payment (YYYY-MM-DD).",
+ "currency": "The currency of the invoice amounts.",
+ "status": "The current status of the invoice (for example DRAFT).",
+ "amount": "The total amount of the invoice, including tax.",
+ "tax": "The tax amount applied to the invoice.",
+ "subTotal": "The total amount of the invoice, excluding tax.",
+ "amountOutstanding": "The balance that remains to be paid.",
+ "amountPaid": "The total amount paid against the invoice.",
+ "amountWrittenOff": "The total amount written off for the invoice.",
+ "company": "The customer company the invoice is billed to.",
+ "projects": "The projects the invoice covers.",
+ "budgets": "The project budgets the invoice draws from.",
+ "fields": "Custom field values set on the invoice.",
+ "createdAt": "When the invoice was created (epoch milliseconds).",
+ "updatedAt": "When the invoice was last modified (epoch milliseconds).",
+ },
+ },
+ "invoice_line_items": {
+ "description": "A line on a Rocketlane invoice, which bills a quantity at a unit price against a project.",
+ "docs_url": "https://developer.rocketlane.com/reference/get-invoice-line-items",
+ "columns": {
+ "invoiceId": "The identifier of the invoice the line belongs to.",
+ "invoiceLineItemId": "The unique identifier of the invoice line item.",
+ "description": "The description of the item or service billed.",
+ "quantity": "The quantity of the item or service.",
+ "unitPrice": "The unit price of the item or service.",
+ "amount": "The total amount of the line (quantity multiplied by unit price).",
+ "sourceId": "The identifier of the entity the line bills, such as a project.",
+ "sourceType": "The type of entity the line bills (for example PROJECT).",
+ "taxCode": "The tax code applied to the line.",
+ "taxComponents": "The tax components that make up the tax code.",
+ "budget": "The project budget the line draws from.",
+ },
+ },
+ "time_entry_categories": {
+ "description": "A Rocketlane time entry category, used to classify logged time.",
+ "docs_url": "https://developer.rocketlane.com/reference/get-time-entry-categories",
+ "columns": {
+ "categoryId": "The unique identifier of the category.",
+ "categoryName": "The name of the category.",
+ },
+ },
+ "phases": {
+ "description": "A Rocketlane phase, a stage of a project that groups its tasks.",
+ "docs_url": "https://developer.rocketlane.com/reference/get-all-phases",
+ "columns": {
+ "phaseId": "The unique, system-generated identifier of the phase.",
+ "phaseName": "The name of the phase.",
+ "project": "The project the phase belongs to.",
+ "phaseDescription": "The description of the phase.",
+ "startDate": "The planned start date of the phase (YYYY-MM-DD).",
+ "dueDate": "The planned due date of the phase (YYYY-MM-DD).",
+ "startDateActual": "The date the phase actually started (YYYY-MM-DD).",
+ "dueDateActual": "The date the phase was actually completed (YYYY-MM-DD).",
+ "status": "The current phase status, as a value and label pair.",
+ "budgets": "The project budgets linked to the phase.",
+ "private": "Whether the phase is private or shared.",
+ "createdAt": "When the phase was created (epoch milliseconds).",
+ "updatedAt": "When the phase was last modified (epoch milliseconds).",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/rocketlane/rocketlane.py b/products/warehouse_sources/backend/temporal/data_imports/sources/rocketlane/rocketlane.py
index ffc6087c8bb9..078206ea5327 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/rocketlane/rocketlane.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/rocketlane/rocketlane.py
@@ -1,5 +1,5 @@
import dataclasses
-from typing import Any, Optional
+from typing import Any, Optional, cast
from requests import Request, Response
@@ -8,27 +8,36 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.res
RESTAPIConfig,
rest_api_resource,
)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (
+ build_dependent_resource,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import BasePaginator
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.resource import Resource
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import ClientConfig
from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse
-from products.warehouse_sources.backend.temporal.data_imports.sources.rocketlane.settings import ROCKETLANE_ENDPOINTS
+from products.warehouse_sources.backend.temporal.data_imports.sources.rocketlane.settings import (
+ PAGE_SIZE,
+ ROCKETLANE_ENDPOINTS,
+ RocketlaneEndpointConfig,
+)
ROCKETLANE_BASE_URL = "https://api.rocketlane.com/api/1.0"
-# The list endpoints cap `pageSize` at 100 (values above the cap fall back to 100), so 100 minimises
-# round trips.
-PAGE_SIZE = 100
# Cheap endpoint used to confirm an api-key is genuine. The key is account-wide, so one probe
# validates access to every list endpoint.
DEFAULT_PROBE_PATH = "/users"
[email protected] # nosemgrep: prefer-frozen-dataclasses -- pre-existing; new field shifts the backlog finding into diff
class RocketlaneResumeConfig:
# Opaque cursor for the next page. Rocketlane returns a `nextPageToken` alongside `hasMore`; a
# crashed full-refresh sync resumes from the last token it persisted. Note: Rocketlane tokens are
# only valid for ~15 minutes, so a long-stalled resume may need to restart from the first page —
# merge dedupes on the primary key either way.
page_token: Optional[str] = None
+ # Fan-out endpoints checkpoint the parents already synced and the child cursor of the one in
+ # progress, in the shape the shared fan-out framework produces.
+ fanout_state: Optional[dict[str, Any]] = None
def _headers() -> dict[str, str]:
@@ -96,6 +105,74 @@ class RocketlaneCursorPaginator(BasePaginator):
return "RocketlaneCursorPaginator()"
+def _client_config(api_key: str) -> ClientConfig:
+ return {
+ "base_url": ROCKETLANE_BASE_URL,
+ "headers": _headers(),
+ # Rocketlane expects the raw key in an `api-key` header — framework auth redacts it.
+ "auth": {"type": "api_key", "api_key": api_key, "name": "api-key", "location": "header"},
+ "paginator": RocketlaneCursorPaginator(),
+ }
+
+
+def _source_response(endpoint: str, config: RocketlaneEndpointConfig, resource: Resource) -> SourceResponse:
+ return SourceResponse(
+ name=endpoint,
+ items=lambda: resource,
+ primary_keys=config.primary_keys,
+ partition_count=1,
+ partition_size=1,
+ partition_mode="datetime" if config.partition_key else None,
+ partition_format="month" if config.partition_key else None,
+ partition_keys=[config.partition_key] if config.partition_key else None,
+ column_hints=resource.column_hints,
+ )
+
+
+def _fanout_source(
+ api_key: str,
+ endpoint: str,
+ config: RocketlaneEndpointConfig,
+ team_id: int,
+ job_id: str,
+ resumable_source_manager: ResumableSourceManager[RocketlaneResumeConfig],
+) -> SourceResponse:
+ assert config.fanout is not None
+
+ initial_state: Optional[dict[str, Any]] = None
+ if resumable_source_manager.can_resume():
+ resume = resumable_source_manager.load_state()
+ if resume is not None and resume.fanout_state:
+ initial_state = resume.fanout_state
+
+ def save_checkpoint(state: Optional[dict[str, Any]]) -> None:
+ if state:
+ resumable_source_manager.save_state(RocketlaneResumeConfig(fanout_state=state))
+
+ resource = build_dependent_resource(
+ endpoint_configs=ROCKETLANE_ENDPOINTS,
+ child_endpoint=endpoint,
+ fanout=config.fanout,
+ client_config=_client_config(api_key),
+ path_format_values={},
+ team_id=team_id,
+ job_id=job_id,
+ db_incremental_field_last_value=None,
+ parent_endpoint_extra={"data_selector": "data", "data_selector_required": True},
+ # Explicit, because the framework reads a path ending in a placeholder (`?projectId={projectId}`)
+ # as a single-entity fetch and would otherwise stop after the first page.
+ child_endpoint_extra={
+ "data_selector": "data",
+ "data_selector_required": True,
+ "paginator": RocketlaneCursorPaginator(),
+ },
+ page_size_param="pageSize",
+ resume_hook=save_checkpoint,
+ initial_paginator_state=initial_state,
+ )
+ return _source_response(endpoint, config, cast(Resource, resource))
+
+
def rocketlane_source(
api_key: str,
endpoint: str,
@@ -106,14 +183,11 @@ def rocketlane_source(
) -> SourceResponse:
config = ROCKETLANE_ENDPOINTS[endpoint]
+ if config.fanout is not None:
+ return _fanout_source(api_key, endpoint, config, team_id, job_id, resumable_source_manager)
+
rest_config: RESTAPIConfig = {
- "client": {
- "base_url": ROCKETLANE_BASE_URL,
- "headers": _headers(),
- # Rocketlane expects the raw key in an `api-key` header — framework auth redacts it.
- "auth": {"type": "api_key", "api_key": api_key, "name": "api-key", "location": "header"},
- "paginator": RocketlaneCursorPaginator(),
- },
+ "client": _client_config(api_key),
"resource_defaults": {},
"resources": [
{
@@ -152,17 +226,7 @@ def rocketlane_source(
initial_paginator_state=initial_paginator_state,
)
- return SourceResponse(
- name=endpoint,
- items=lambda: resource,
- primary_keys=config.primary_keys,
- partition_count=1,
- partition_size=1,
- partition_mode="datetime" if config.partition_key else None,
- partition_format="month" if config.partition_key else None,
- partition_keys=[config.partition_key] if config.partition_key else None,
- column_hints=resource.column_hints,
- )
+ return _source_response(endpoint, config, resource)
def check_access(api_key: str, path: str = DEFAULT_PROBE_PATH) -> tuple[int, Optional[str]]:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/rocketlane/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/rocketlane/settings.py
index f5e070325cf2..f4fc18451651 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/rocketlane/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/rocketlane/settings.py
@@ -1,8 +1,16 @@
-from dataclasses import dataclass
-from typing import Optional
+from dataclasses import dataclass, field
+from typing import Any, Optional
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (
+ DependentEndpointConfig,
+)
-@dataclass
+# The list endpoints cap `pageSize` at 100 (values above the cap fall back to 100), so 100 minimises
+# round trips.
+PAGE_SIZE = 100
+
+
+@dataclass # nosemgrep: prefer-frozen-dataclasses -- pre-existing; new field shifts the backlog finding into diff
class RocketlaneEndpointConfig:
name: str
path: str
@@ -13,13 +21,16 @@ class RocketlaneEndpointConfig:
# Rocketlane timestamps are epoch milliseconds; only set this where the field is genuinely
# immutable — never `updatedAt`, which changes on every edit.
partition_key: Optional[str] = None
+ # Set for endpoints that take a parent id (a `projectId` filter, an invoice id in the path):
+ # they are fetched once per row of the parent endpoint.
+ fanout: Optional[DependentEndpointConfig] = None
+ page_size: int = PAGE_SIZE
+ incremental_fields: list[Any] = field(default_factory=list)
+ default_incremental_field: Optional[str] = None
-# Rocketlane list endpoints that can be pulled without a parent id. Endpoints that require a
-# `projectId` query parameter (phases, spaces, ...) are intentionally excluded — they are per-parent
-# fan-outs, not account-level lists. All are full-refresh only: Rocketlane's list endpoints expose
-# per-field filters but no single documented `updated_after` cursor, so there is no genuine
-# incremental cursor to advance.
+# All endpoints are full-refresh only: Rocketlane's list endpoints expose per-field filters but no
+# single documented `updated_after` cursor, so there is no genuine incremental cursor to advance.
ROCKETLANE_ENDPOINTS: dict[str, RocketlaneEndpointConfig] = {
"projects": RocketlaneEndpointConfig(
name="projects", path="/projects", primary_keys=["projectId"], partition_key="createdAt"
@@ -32,6 +43,43 @@ ROCKETLANE_ENDPOINTS: dict[str, RocketlaneEndpointConfig] = {
"fields": RocketlaneEndpointConfig(
name="fields", path="/fields", primary_keys=["fieldId"], partition_key="createdAt"
),
+ "invoices": RocketlaneEndpointConfig(
+ name="invoices", path="/invoices", primary_keys=["invoiceId"], partition_key="createdAt"
+ ),
+ # Line items carry no timestamps and the API does not document their ids as globally unique, so
+ # the parent invoice id is part of the key.
+ "invoice_line_items": RocketlaneEndpointConfig(
+ name="invoice_line_items",
+ path="/invoices/{invoiceId}/lines",
+ primary_keys=["invoiceId", "invoiceLineItemId"],
+ fanout=DependentEndpointConfig(
+ parent_name="invoices",
+ resolve_param="invoiceId",
+ resolve_field="invoiceId",
+ include_from_parent=["invoiceId"],
+ parent_field_renames={"invoiceId": "invoiceId"},
+ # An invoice deleted between the parent listing and this fetch must not fail the fan-out.
+ child_response_actions=[{"status_code": 404, "action": "ignore"}],
+ ),
+ ),
+ "time_entry_categories": RocketlaneEndpointConfig(
+ name="time_entry_categories", path="/time-entries/categories", primary_keys=["categoryId"]
+ ),
+ # `/phases` requires a `projectId` filter. Each phase row already carries its `project`, and
+ # `phaseId` is documented as globally unique.
+ "phases": RocketlaneEndpointConfig(
+ name="phases",
+ path="/phases?projectId={projectId}",
+ primary_keys=["phaseId"],
+ partition_key="createdAt",
+ fanout=DependentEndpointConfig(
+ parent_name="projects",
+ resolve_param="projectId",
+ resolve_field="projectId",
+ include_from_parent=[],
+ child_response_actions=[{"status_code": 404, "action": "ignore"}],
+ ),
+ ),
}
ENDPOINTS = tuple(ROCKETLANE_ENDPOINTS.keys())
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/rocketlane/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/rocketlane/source.py
index 78e2e772709e..045b3add9afa 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/rocketlane/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/rocketlane/source.py
@@ -53,7 +53,7 @@ class RocketlaneSource(ResumableSource[RocketlaneSourceConfig, RocketlaneResumeC
releaseStatus=ReleaseStatus.ALPHA,
caption="""Enter your Rocketlane API key to pull your Rocketlane data into the PostHog Data warehouse.
-You can generate an API key under **Settings → API** in the [Rocketlane app](https://app.rocketlane.com/). This single key grants read access to your projects, tasks, time entries, users, and fields.
+You can generate an API key under **Settings → API** in the [Rocketlane app](https://app.rocketlane.com/). This single key grants read access to your projects, phases, tasks, time entries, users, fields, and invoices.
""",
iconPath="/static/services/rocketlane.png",
docsUrl="https://posthog.com/docs/cdp/sources/rocketlane",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/rocketlane/tests/test_rocketlane.py b/products/warehouse_sources/backend/temporal/data_imports/sources/rocketlane/tests/test_rocketlane.py
index cd0dfd7d1923..366d25c288f9 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/rocketlane/tests/test_rocketlane.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/rocketlane/tests/test_rocketlane.py
@@ -71,6 +71,101 @@ class TestPagination:
assert "matched nothing" in str(result.raised)
+class TestFanout:
+ @parameterized.expand(
+ [
+ (
+ "phases",
+ "projects",
+ "projectId",
+ ["/api/1.0/projects", "/api/1.0/phases", "/api/1.0/phases", "/api/1.0/phases"],
+ [None, "1", "1", "2"],
+ [{"phaseId": 10}, {"phaseId": 11}],
+ ),
+ (
+ "invoice_line_items",
+ "invoices",
+ "invoiceId",
+ [
+ "/api/1.0/invoices",
+ "/api/1.0/invoices/1/lines",
+ "/api/1.0/invoices/1/lines",
+ "/api/1.0/invoices/2/lines",
+ ],
+ [None, None, None, None],
+ [{"invoiceLineItemId": 10, "invoiceId": 1}, {"invoiceLineItemId": 11, "invoiceId": 1}],
+ ),
+ ]
+ )
+ def test_walks_child_pages_per_parent_and_skips_missing_parent(
+ self,
+ endpoint: str,
+ _parent: str,
+ parent_key: str,
+ expected_paths: list[str],
+ expected_project_ids: list[str | None],
+ expected_rows: list[dict[str, Any]],
+ ) -> None:
+ child_key = next(iter(expected_rows[0]))
+ result = _driver().run(
+ endpoint,
+ [
+ _response([{parent_key: 1}, {parent_key: 2}], has_more=False, next_token=None),
+ _response([{child_key: 10}], has_more=True, next_token="p2"),
+ _response([{child_key: 11}], has_more=False, next_token=None),
+ # The second parent was deleted after the parent listing.
+ ScriptedResponse(status=404, json={"errors": []}),
+ ],
+ )
+
+ assert result.raised is None
+ assert result.rows == expected_rows
+ assert result.paths == expected_paths
+ assert result.params("projectId") == expected_project_ids
+ assert result.params("pageToken") == [None, None, "p2", None]
+ assert result.params("pageSize") == ["100", "100", "100", "100"]
+
+ @parameterized.expand(
+ [
+ (
+ "skips_completed_parent",
+ {"completed": ["/phases?projectId=1"], "current": None, "child_state": None},
+ ["2"],
+ [None],
+ [{"phaseId": 20}],
+ ),
+ (
+ "continues_parent_in_progress",
+ {"completed": [], "current": "/phases?projectId=1", "child_state": {"page_token": "p2"}},
+ ["1", "2"],
+ ["p2", None],
+ [{"phaseId": 20}, {"phaseId": 20}],
+ ),
+ ]
+ )
+ def test_resumes_from_saved_fanout_state(
+ self,
+ _name: str,
+ fanout_state: dict[str, Any],
+ expected_project_ids: list[str],
+ expected_page_tokens: list[str | None],
+ expected_rows: list[dict[str, Any]],
+ ) -> None:
+ result = _driver().run(
+ "phases",
+ [
+ _response([{"projectId": 1}, {"projectId": 2}], has_more=False, next_token=None),
+ *[_response([{"phaseId": 20}], has_more=False, next_token=None) for _ in expected_project_ids],
+ ],
+ resume_state=RocketlaneResumeConfig(fanout_state=fanout_state),
+ )
+
+ assert result.rows == expected_rows
+ assert result.params("projectId")[1:] == expected_project_ids
+ assert result.params("pageToken")[1:] == expected_page_tokens
+ assert result.saved_states[-1].fanout_state["completed"] == ["/phases?projectId=1", "/phases?projectId=2"]
+
+
class TestCheckAccess:
@parameterized.expand(
[
@@ -94,20 +189,25 @@ class TestCheckAccess:
class TestRocketlaneSourceResponse:
@parameterized.expand(
[
- ("projects", ["projectId"]),
- ("tasks", ["taskId"]),
- ("time_entries", ["timeEntryId"]),
- ("users", ["userId"]),
- ("fields", ["fieldId"]),
+ ("projects", ["projectId"], "createdAt"),
+ ("tasks", ["taskId"], "createdAt"),
+ ("time_entries", ["timeEntryId"], "createdAt"),
+ ("users", ["userId"], "createdAt"),
+ ("fields", ["fieldId"], "createdAt"),
+ ("invoices", ["invoiceId"], "createdAt"),
+ ("invoice_line_items", ["invoiceId", "invoiceLineItemId"], None),
+ ("time_entry_categories", ["categoryId"], None),
+ ("phases", ["phaseId"], "createdAt"),
]
)
- def test_response_uses_endpoint_primary_key(self, endpoint: str, primary_keys: list[str]) -> None:
+ def test_response_uses_endpoint_primary_key(
+ self, endpoint: str, primary_keys: list[str], partition_key: str | None
+ ) -> None:
result = _driver().run(endpoint, [_response([], has_more=False, next_token=None)])
response = result.response
assert response is not None
assert response.name == endpoint
assert response.primary_keys == primary_keys
- # Every endpoint exposes a stable `createdAt`, so all partition by datetime.
- assert response.partition_mode == "datetime"
- assert response.partition_keys == ["createdAt"]
+ assert response.partition_mode == ("datetime" if partition_key else None)
+ assert response.partition_keys == ([partition_key] if partition_key else None)