exp: Propagate column types between nodes #3913
Merged
+390
−16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
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.tableandcolumnparameters optional inparsePerfettoSqlTypeFromString()to support contexts where table/column info isn't available.Properly errors when plain 'id' type is parsed without context.
Type Inference Rules
The implementation follows these type inference rules for aggregations:
COUNT,COUNT_ALL→INTSUM,MIN,MAX→ Preserves input column typeMEAN,MEDIAN,DURATION_WEIGHTED_MEAN,PERCENTILE→DOUBLEINT(with warning)