Skip to content

[ZEPPELIN-6471] Share a single aggregation-type constant between table and pivot#5313

Open
kimyenac wants to merge 1 commit into
apache:masterfrom
kimyenac:ZEPPELIN-6471
Open

[ZEPPELIN-6471] Share a single aggregation-type constant between table and pivot#5313
kimyenac wants to merge 1 commit into
apache:masterfrom
kimyenac:ZEPPELIN-6471

Conversation

@kimyenac

Copy link
Copy Markdown
Contributor

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 AggregationType union plus a value array; the pivot component had only an untyped string[] 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?

  • Add common/util/aggregation-type.ts exporting AGGREGATION_TYPES (as const) and AggregationType = (typeof AGGREGATION_TYPES)[number] as the single source of truth.
  • table-visualization.component.ts: remove the local, unexported AggregationType type and the duplicated literal array; import the shared definition. aggregations is now readonly AggregationType[].
  • pivot-setting.component.ts: replace the untyped string[] with readonly AggregationType[] from the shared constant, consistent with the table component.

Both usages are read-only iteration/display (@for), so as const / readonly is 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:

cd zeppelin-web-angular && npm run lint && npm run build:angular

Both pass (0 lint errors, successful production build). Manually verified the pivot aggregation dropdown still shows sum, count, avg, min, max.

Questions

  • Does the license files need to update? No
  • Is there breaking change for older versions? No
  • Does this needs documentation? No

…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).
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.

1 participant