Skip to content

fix: convert anonymous classes to named inner classes for Jackson serialization - #20070

Open
zhang-arvin wants to merge 1 commit into
apache:masterfrom
zhang-arvin:fix/7599-aggregator-factory-jackson
Open

fix: convert anonymous classes to named inner classes for Jackson serialization#20070
zhang-arvin wants to merge 1 commit into
apache:masterfrom
zhang-arvin:fix/7599-aggregator-factory-jackson

Conversation

@zhang-arvin

Copy link
Copy Markdown

Purpose

Fix Jackson serialization failure for Long/Double/Float First/Last aggregator factories.

Anonymous inner classes used as NIL_AGGREGATOR and NIL_BUFFER_AGGREGATOR were being serialized
as LongLastAggregatorFactory$1 instead of the registered @JsonTypeName. This caused the error:

Could not resolve type id 'LongLastAggregatorFactory$1' into a subtype of AggregatorFactory

Changes

Converted all anonymous subclasses of Aggregator and BufferAggregator in the following 6 factory
classes to private static named inner classes:

  • LongLastAggregatorFactory
  • DoubleLastAggregatorFactory
  • FloatLastAggregatorFactory
  • LongFirstAggregatorFactory
  • DoubleFirstAggregatorFactory
  • FloatFirstAggregatorFactory

Each factory previously had two anonymous classes (NIL_AGGREGATOR and NIL_BUFFER_AGGREGATOR)
that overrode aggregate() to be no-ops. These are now named inner classes (e.g.,
NilLongLastAggregator, NilLongLastBufferAggregator) that correctly extend their parent classes
with explicit constructors.

Closes #7599

…ialization

Anonymous subclasses in Long/Double/Float First/Last aggregator factories
were being serialized as LongLastAggregatorFactory$1 instead of the
registered @JsonTypeName. This caused 'Could not resolve type id' errors
during Jackson deserialization.

Converted all NIL_AGGREGATOR and NIL_BUFFER_AGGREGATOR anonymous classes
to private static named inner classes in all 6 factory classes.

Closes apache#7599

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Severity Findings
P0 0
P1 1
P2 2
P3 0
Total 3

Reviewed 6 of 6 changed files.

The review found one unresolved Jackson-type risk, two remaining anonymous NIL paths, and missing serialization regression coverage.


This is an automated review by Codex GPT-5.6-Luna(max)

)
private static final Aggregator NIL_AGGREGATOR = new NilLongLastAggregator();

private static class NilLongLastAggregator extends LongLastAggregator

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[P1] Named NIL class does not fix the Jackson type ID

NilLongLastAggregator extends LongLastAggregator, not AggregatorFactory. The Jackson subtype registration applies to the factory, while the static NIL field is not serialized. If the NIL object is serialized directly, it still has no registered longLast type, so the change does not demonstrably fix the reported serialization failure.

NilColumnValueSelector.instance(),
false
)
private static final Aggregator NIL_AGGREGATOR = new NilDoubleFirstAggregator();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[P2] Anonymous NIL implementations remain elsewhere

The conversion is incomplete: anonymous NIL implementations remain in StringFirstAggregatorFactory, StringLastAggregatorFactory, and the numeric Any factories. The same class-name serialization risk therefore remains for those absent-column paths if runtime aggregators are serialized.

NilColumnValueSelector.instance(),
false
)
private static final Aggregator NIL_AGGREGATOR = new NilLongLastAggregator();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[P2] No serialization regression test covers the fix

Existing serde tests only deserialize hard-coded factory JSON; they do not serialize a factory or exercise NIL factorization. Add round-trip coverage for the affected types and the missing-column branch.

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.

Could not resolve type id 'LongLastAggregatorFactory$1' into a subtype of AggregatorFactory

2 participants