Skip to content

Conversation

@WZhuo
Copy link
Contributor

@WZhuo WZhuo commented Jan 7, 2026

No description provided.

@WZhuo
Copy link
Contributor Author

WZhuo commented Jan 7, 2026

   Types.TimestampType type = Types.TimestampType.withoutZone();
    Literal<Long> ts = Literal.of("2017-12-01T10:12:55.038194").to(type);
    Literal<Long> pts = Literal.of("1970-01-01T00:00:01.000001").to(type);
    Literal<Long> nts = Literal.of("1969-12-31T23:59:59.999999").to(type);

    Transform<Long, Integer> years = Transforms.year();
    assertThat((int) years.bind(type).apply(ts.value()))
        .as("Should produce 2017 - 1970 = 47")
        .isEqualTo(47);
    assertThat((int) years.bind(type).apply(pts.value()))
        .as("Should produce 1970 - 1970 = 0")
        .isZero();
    assertThat((int) years.bind(type).apply(nts.value()))
        .as("Should produce 1969 - 1970 = -1")
        .isEqualTo(-1);

Above is the YearTransform's test case in Java, it should return delta years between the time and 1970.

@zhjwpku
Copy link
Collaborator

zhjwpku commented Jan 7, 2026

Good catch, you may also want to change the comments of Transform::Year() and YearTransform.

@WZhuo WZhuo changed the title fix: YearTransform return delta years from 1970 fix: YearTransform return years since 1970 Jan 8, 2026
@wgtmac wgtmac merged commit 40834dd into apache:main Jan 8, 2026
10 checks passed
@wgtmac
Copy link
Member

wgtmac commented Jan 8, 2026

Thanks @WZhuo for fixing this and @zhjwpku for the review!

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.

3 participants