Skip to content

Conversation

@aMayzner
Copy link
Member

Summary

Implements type propagation across query builder nodes to preserve column type information through transformations. Previously, column types were often lost when flowing through nodes (add columns, aggregations, etc.), leading to loss of semantic information like TIMESTAMP, DURATION, etc. The implementation includes proper type inference for aggregations and warnings when type information cannot be determined.

Changes

  • AddColumnsNode: Preserves types from source columns when selecting columns and when creating computed columns with stored type information. Logs warnings whenstored type parsing fails.
  • AggregationNode: Adds getAggregationResultType() helper to determine correct result types based on operation semantics (COUNT→INT, MEAN/MEDIAN→DOUBLE, SUM/MIN/MAX preserve input type). Logs warnings when type information is missing for operations that should preserve it.
  • TimeRangeSourceNode: Explicitly specifies column types (id→INT, ts→TIMESTAMP, dur→DURATION) as a proper source node pattern.
  • Type parser: Made table and column parameters optional in parsePerfettoSqlTypeFromString() to support contexts where table/column info isn't available.
    Properly errors when plain 'id' type is parsed without context.
  • Tests: Added comprehensive unit tests for type propagation in aggregation and timerange source nodes, covering all aggregation operations and edge cases.
  • Debugging: Added console warnings when falling back to default INT type, helping developers identify and debug type propagation issues.

Type Inference Rules

The implementation follows these type inference rules for aggregations:

  • COUNT, COUNT_ALLINT
  • SUM, MIN, MAX → Preserves input column type
  • MEAN, MEDIAN, DURATION_WEIGHTED_MEAN, PERCENTILEDOUBLE
  • Unknown/missing type → INT (with warning)

@aMayzner aMayzner requested a review from a team as a code owner November 29, 2025 16:38
@github-actions
Copy link

🎨 Perfetto UI Build

✅ UI build is ready: https://storage.googleapis.com/perfetto-ci-artifacts/gh-19786515871-ui/ui/index.html

@aMayzner aMayzner requested a review from stevegolton November 29, 2025 16:52
@aMayzner aMayzner merged commit d4f643b into main Dec 1, 2025
17 checks passed
@aMayzner aMayzner deleted the dev/mayzner/propagate-column-types branch December 1, 2025 09:52
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