Skip to content

Conversation

@cabljac
Copy link
Contributor

@cabljac cabljac commented Jan 9, 2026

Fixes #2557

Manual Testing

image (3) image (4)

@cabljac cabljac changed the title test(gen-schema-views): add failing tests asserting a better structur… wip: better gen-schema-view queries Jan 9, 2026
@HassanBahati HassanBahati changed the title wip: better gen-schema-view queries refactor(firestore-bigquery-export): refactor fs-bq-schema-views to use CTE query builder Jan 9, 2026
@cabljac cabljac marked this pull request as ready for review January 9, 2026 15:27
const firstValue = (selector: string, isArrayType?: boolean) => {
if (isArrayType) return selector;
return `FIRST_VALUE(${selector}) OVER(PARTITION BY document_name ORDER BY timestamp DESC)`;
// For CTE + JOIN pattern, we don't need window functions - just return the selector as-is
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this now?

// Replace JSON_EXTRACT(data, with JSON_EXTRACT(t.data,
// But be careful not to replace if already "t.data"
let updatedExtractor = String(extractor);
if (!updatedExtractor.includes("t.data")) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this check required since you're technically replacing JSON_EXTRACT_SCALAR(data with JSON_EXTRACT_SCALAR(t.data etc?

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.

🐛 [fs-bq-schema-views] Excessive first_value() over (partition by) clauses causes BQ resource exhaustion

3 participants