Skip to content

Conversation

@godfreyhe
Copy link
Contributor

@godfreyhe godfreyhe commented Nov 12, 2019

What is the purpose of the change

Most tests from package o.a.f.table.planner.functions.aggfunctions are not executed during mvn test because those test case classed are abstract class and will be ignored when running mvn test. In FLINK-13702, BinaryGeneric can't be compared directly, so those failures are also ignored. This pr aims to fix both. The first one's solution is introducing Enclosed runner, and moving the abstract class as an inner class, and making sure the outer class is a non-abstract class. The second one's solution is verifying BinaryGeneric using BinaryGenericAsserter.equivalent (should also consider that GenericRow has BinaryGeneric sub-type)

Brief change log

  • introducing Enclosed runner and make sure the outer class is a non-abstract class
  • comparing BinaryGeneric using BinaryGenericAsserter.equivalent

Verifying this change

This change is already covered by existing tests.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (yes / no)
  • The public API, i.e., is any changed class annotated with @Public(Evolving): (yes / no)
  • The serializers: (yes / no / don't know)
  • The runtime per-record code paths (performance sensitive): (yes / no / don't know)
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: (yes / no / don't know)
  • The S3 file system connector: (yes / no / don't know)

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

…le.planner.functions.aggfunctions are not executed during mvn test and fix BinaryGeneric comparison failure
@flinkbot
Copy link
Collaborator

flinkbot commented Nov 12, 2019

Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.

Automated Checks

Last check on commit 6905159 (Wed Dec 04 15:23:50 UTC 2019)

Warnings:

  • No documentation files were touched! Remember to keep the Flink docs up to date!

Mention the bot in a comment to re-run the automated checks.

Review Progress

  • ❓ 1. The [description] looks good.
  • ❓ 2. There is [consensus] that the contribution should go into to Flink.
  • ❓ 3. Needs [attention] from.
  • ❓ 4. The change fits into the overall [architecture].
  • ❓ 5. Overall code [quality] is good.

Please see the Pull Request Review Guide for a full explanation of the review process.

Details
The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commands
The @flinkbot bot supports the following commands:

  • @flinkbot approve description to approve one or more aspects (aspects: description, consensus, architecture and quality)
  • @flinkbot approve all to approve all aspects
  • @flinkbot approve-until architecture to approve everything until architecture
  • @flinkbot attention @username1 [@username2 ..] to require somebody's attention
  • @flinkbot disapprove architecture to remove an approval you gave earlier

@wuchong
Copy link
Member

wuchong commented Nov 12, 2019

cc @dawidwys

@flinkbot
Copy link
Collaborator

flinkbot commented Nov 12, 2019

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run travis re-run the last Travis build

Copy link
Contributor

@dawidwys dawidwys left a comment

Choose a reason for hiding this comment

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

Hi @godfreyhe thank you for the PR. I would suggest improving the code quality of the AggFunctionTestBase#validateResult method.

As for the general problem with the tests I think those tests are much better suited for parameterized tests. You can see some examples of such tests e.g. here: org.apache.flink.table.types.LogicalTypeParserTest. They change just the type of the accumulator, if I understood the tests correctly.

I am fine though with the changes in this PR for now, but would strongly encourage to not introduce any more of such complex tests hierarchy (at least 3 levels of inheritance)

assertEquals(e.mapSize, r.mapSize);
} else {
// verify null
if (expected == null || result == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This code block can be significantly improved:

	protected <E> void validateResult(E expected, E result, TypeInformation<?> typeInfo) {
		if (expected instanceof BigDecimal && result instanceof BigDecimal) {
			// BigDecimal.equals() value and scale but we are only interested in value.
			assertEquals(0, ((BigDecimal) expected).compareTo((BigDecimal) result));
		} else if (expected instanceof MinWithRetractAccumulator &&
				result instanceof MinWithRetractAccumulator) {
			MinWithRetractAccumulator e = (MinWithRetractAccumulator) expected;
			MinWithRetractAccumulator r = (MinWithRetractAccumulator) result;
			assertEquals(e.min, r.min);
			assertEquals(e.mapSize, r.mapSize);
		} else if (expected instanceof MaxWithRetractAccumulator &&
				result instanceof MaxWithRetractAccumulator) {
			MaxWithRetractAccumulator e = (MaxWithRetractAccumulator) expected;
			MaxWithRetractAccumulator r = (MaxWithRetractAccumulator) result;
			assertEquals(e.max, r.max);
			assertEquals(e.mapSize, r.mapSize);
		} else if (expected instanceof BinaryGeneric && result instanceof BinaryGeneric) {
			TypeSerializer<?> serializer = typeInfo.createSerializer(new ExecutionConfig());
			assertThat(
				(BinaryGeneric) result,
				equivalent((BinaryGeneric) expected, new BinaryGenericSerializer<>(serializer)));
		} else if (expected instanceof GenericRow && result instanceof GenericRow) {
			validateGenericRow(
				(GenericRow) expected,
				(GenericRow) result,
				(BaseRowTypeInfo) typeInfo);
		} else {
			assertEquals(expected, result);
		}
	}

	private void validateGenericRow(GenericRow expected, GenericRow result, BaseRowTypeInfo typeInfo) {
		assertEquals(expected.getArity(), result.getArity());

		for (int i = 0; i < expected.getArity(); ++i) {
			Object expectedObj = expected.getField(i);
			Object resultObj = result.getField(i);
			validateResult(expectedObj, resultObj, typeInfo.getTypeAt(i));
		}
	}

@godfreyhe
Copy link
Contributor Author

@dawidwys thanks so much for the suggestion, and I have updated the PR

@dawidwys dawidwys merged commit dcc1330 into apache:master Nov 18, 2019
@godfreyhe godfreyhe deleted the FLINK-14694 branch December 17, 2019 12:41
dawidwys pushed a commit to dawidwys/flink that referenced this pull request Feb 4, 2020
…est compilation error due to incompatible types

This partially reverts the commit dcc1330 and uses the initial approach from apache#10158 of using Enclosed annotation. The problem with the TestSpec approach was that the top level classes shouldn't use generics as they are stripped when instantiated by JUnit runner which may lead to generic signature mismatch.
dawidwys pushed a commit that referenced this pull request Feb 5, 2020
…est compilation error due to incompatible types

This partially reverts the commit dcc1330 and uses the initial approach from #10158 of using Enclosed annotation. The problem with the TestSpec approach was that the top level classes shouldn't use generics as they are stripped when instantiated by JUnit runner which may lead to generic signature mismatch.

This closes #10915
dawidwys pushed a commit that referenced this pull request Feb 5, 2020
…est compilation error due to incompatible types

This partially reverts the commit dcc1330 and uses the initial approach from #10158 of using Enclosed annotation. The problem with the TestSpec approach was that the top level classes shouldn't use generics as they are stripped when instantiated by JUnit runner which may lead to generic signature mismatch.

This closes #10915
JTaky pushed a commit to JTaky/flink that referenced this pull request Feb 20, 2020
…est compilation error due to incompatible types

This partially reverts the commit dcc1330 and uses the initial approach from apache#10158 of using Enclosed annotation. The problem with the TestSpec approach was that the top level classes shouldn't use generics as they are stripped when instantiated by JUnit runner which may lead to generic signature mismatch.

This closes apache#10915
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants