Skip to content

[#7332] feat(api): Support statistic interfaces #7333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jul 2, 2025

Conversation

jerqi
Copy link
Contributor

@jerqi jerqi commented Jun 4, 2025

What changes were proposed in this pull request?

Support statistic interfaces

Why are the changes needed?

Fix: #7332

Does this PR introduce any user-facing change?

Yes, I will add the document

How was this patch tested?

Code review

@jerqi jerqi marked this pull request as draft June 4, 2025 13:25
@jerqi jerqi force-pushed the ISSUE-7270 branch 4 times, most recently from 55ab5d2 to c5f0cc3 Compare June 5, 2025 06:36
@jerqi jerqi self-assigned this Jun 5, 2025
@jerqi jerqi requested review from jerryshao, FANNG1 and mchades June 5, 2025 06:37
@jerqi jerqi marked this pull request as ready for review June 5, 2025 06:37
*/
List<Statistic> updateStatistics(Map<String, Literal> statistics)
throws UnmodifiableStatisticException, IllegalStatisticNameException;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need an interface to drop the statistics?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I seems more clear to add dropStatistics. I can add it.

@jerqi jerqi requested review from jerryshao and mchades June 23, 2025 06:33
* @param values the list of statistic values to be held by this statistic value
* @return a ListValue instance containing the provided list of statistic values
*/
public static ListValue listValue(List<StatisticValue> values) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should you change to ListValue<T>, what is the type of StatisticValue in the list?

}

/** A statistic value that holds a Map of String keys to other statistic values. */
public static class ObjectValue implements StatisticValue<Map<String, StatisticValue>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why call it ObjectValue, not MapValue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In our type system, MapValue need the same value type. I refer to the json style, named it to objectValue.

* @param values the map of string keys to statistic values to be held by this statistic value
* @return an ObjectValue instance containing the provided map of statistic values
*/
public static ObjectValue objectValue(Map<String, StatisticValue> values) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Java will complain about removing the type for StatisticValue here, can you figure out a better solution?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I addressed the warning.

* @param statistics a map of statistic names to their values
* @return a list of updated statistics
*/
List<Statistic> updateStatistics(Map<String, StatisticValue> statistics)
Copy link
Contributor

Choose a reason for hiding this comment

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

Also here, since you introduce the type definition for StatisticValue, removing the type will make Java compiler warning.

Copy link
Contributor Author

@jerqi jerqi Jun 30, 2025

Choose a reason for hiding this comment

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

I addressed the warning.

@jerqi jerqi requested a review from jerryshao June 30, 2025 06:56
@jerryshao
Copy link
Contributor

I don't have further comments, @mchades @FANNG1 can you please take a review also.


/**
* The statistic is predefined by Gravitino if the value is true. The statistic is defined by
* users if the value if false. For example, the statistic "row_count" is a reserved statistic, A
Copy link
Contributor

Choose a reason for hiding this comment

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

if the value is false

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

public void testLiterals() {
StatisticValues.BooleanValue booleanValue = StatisticValues.booleanValue(true);
Assertions.assertTrue(booleanValue.value());
Assertions.assertEquals(booleanValue.dataType(), Types.BooleanType.get());
Copy link
Contributor

Choose a reason for hiding this comment

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

StatisticValues.BooleanValue b1 = StatisticValues.booleanValue(true);
StatisticValues.BooleanValue b2 = StatisticValues.booleanValue(true);

Will these two statistic values be equals?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the equals and hashCode to fix this issue.

@jerqi jerqi requested a review from mchades July 1, 2025 11:23
Copy link
Contributor

@mchades mchades left a comment

Choose a reason for hiding this comment

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

LGTM.

@jerryshao jerryshao merged commit 106f98b into apache:main Jul 2, 2025
30 checks passed
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.

[Subtask] Add interfaces for statitistic
3 participants