[ZEPPELIN-6471] Share a single aggregation-type constant between table and pivot#5313
Open
kimyenac wants to merge 1 commit into
Open
[ZEPPELIN-6471] Share a single aggregation-type constant between table and pivot#5313kimyenac wants to merge 1 commit into
kimyenac wants to merge 1 commit into
Conversation
…e and pivot Extract AGGREGATION_TYPES and the AggregationType type into common/util/aggregation-type.ts as the single source of truth for the aggregation-type set. Both table-visualization and pivot-setting now import this shared definition; the duplicated literal arrays and the local, unexported AggregationType type are removed. pivot-setting's aggregates field is now typed as readonly AggregationType[], consistent with the table component. The canonical order keeps the pivot's existing order (sum, count, avg, min, max), so the aggregation dropdown display order is unchanged (zero user-visible change).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What is this PR for?
The Angular frontend hardcoded the same aggregation-type set (count, sum, min, max, avg) in two independent places — the table visualization and the pivot setting UI — with no single source of truth. The table component declared a local, unexported
AggregationTypeunion plus a value array; the pivot component had only an untypedstring[]with the same values in a different order. Duplication meant the two could silently drift, and type safety was inconsistent.This PR extracts a single shared constant and matching type, and has both components consume it.
What changes were proposed in this PR?
common/util/aggregation-type.tsexportingAGGREGATION_TYPES(as const) andAggregationType = (typeof AGGREGATION_TYPES)[number]as the single source of truth.table-visualization.component.ts: remove the local, unexportedAggregationTypetype and the duplicated literal array; import the shared definition.aggregationsis nowreadonly AggregationType[].pivot-setting.component.ts: replace the untypedstring[]withreadonly AggregationType[]from the shared constant, consistent with the table component.Both usages are read-only iteration/display (
@for), soas const/readonlyis safe.Canonical order (user-visible decision)
The pivot array directly drives the aggregation dropdown display order. To avoid any user-visible change, the shared constant adopts the pivot's existing order (
sum, count, avg, min, max). The table's internal array is reordered accordingly, but that array does not drive any display, so there is no visible impact. The pivot aggregation dropdown order is unchanged.How should this be tested?
There is no frontend unit-test infrastructure in this project, so regression is confirmed via lint + build:
Both pass (0 lint errors, successful production build). Manually verified the pivot aggregation dropdown still shows
sum, count, avg, min, max.Questions