Skip to content

[FLINK-39195][Table SQL/API] ObjectPath should implement Comparable#27728

Open
Myracle wants to merge 1 commit intoapache:masterfrom
Myracle:FLINK-39195-ObjectPath-comparable
Open

[FLINK-39195][Table SQL/API] ObjectPath should implement Comparable#27728
Myracle wants to merge 1 commit intoapache:masterfrom
Myracle:FLINK-39195-ObjectPath-comparable

Conversation

@Myracle
Copy link
Contributor

@Myracle Myracle commented Mar 3, 2026

What is the purpose of the change

This pull request makes ObjectPath implement the Comparable<ObjectPath> interface, enabling natural ordering of ObjectPath instances. This allows users to sort catalog object paths (e.g., in TreeMap, TreeSet, or Collections.sort()) by database name first, then by object name, which is useful when displaying or processing catalog objects in a deterministic order.

Brief change log

  • Made ObjectPath implement Comparable<ObjectPath>, with comparison based on databaseName first and then objectName
  • Added ObjectPathTest with comprehensive test cases covering comparison, sorting, transitivity, and consistency with equals

Verifying this change

This change added tests and can be verified as follows:

  • Added ObjectPathTest with 8 test cases covering:
    • Comparison with different database names
    • Comparison with same database but different object names
    • Comparison with equal paths
    • Comparison with self
    • Consistency between compareTo and equals
    • Sorting behavior with Collections.sort()
    • Transitivity of the comparison
    • Database name takes precedence over object name in ordering

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

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

Documentation

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

@Myracle Myracle force-pushed the FLINK-39195-ObjectPath-comparable branch from 2e1efbd to b6024ce Compare March 3, 2026 07:25
@flinkbot
Copy link
Collaborator

flinkbot commented Mar 3, 2026

CI report:

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

@Myracle Myracle force-pushed the FLINK-39195-ObjectPath-comparable branch from b6024ce to 1312f6e Compare March 4, 2026 02:26
def get_full_name(self) -> str:
return self._j_object_path.getFullName()

def compare_to(self, other: 'ObjectPath') -> int:
Copy link
Contributor

@rionmonster rionmonster Mar 6, 2026

Choose a reason for hiding this comment

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

We may want to consider adding a series of Python tests for these operations to the existing CatalogTestBase if anything just to exercise these happy paths and any potential edge cases (e.g. comparisons against non-ObjectPath objects such as someObjectPath < 42 as I believe that might return False unexpectedly from the isInstance() check).

@github-actions github-actions bot added the community-reviewed PR has been reviewed by the community. label Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-reviewed PR has been reviewed by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants