You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Myracle (via GitHub)" <gi...@apache.org> on 2026/03/03 07:23:46 UTC
[PR] [FLINK-39195][Table SQL/API] ObjectPath should implement Comparable [flink]
Myracle opened a new pull request, #27728:
URL: https://github.com/apache/flink/pull/27728
## 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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39195][Table SQL/API] ObjectPath should implement Comparable [flink]
Posted by "Myracle (via GitHub)" <gi...@apache.org>.
Myracle commented on code in PR #27728:
URL: https://github.com/apache/flink/pull/27728#discussion_r2909974729
##########
flink-python/pyflink/table/catalog.py:
##########
@@ -1251,6 +1251,21 @@ def get_object_name(self) -> str:
def get_full_name(self) -> str:
return self._j_object_path.getFullName()
+ def compare_to(self, other: 'ObjectPath') -> int:
Review Comment:
Thanks for the sharp catch! You're absolutely right — the isinstance() short-circuit in the comparison dunder methods (__lt__, __le__, __gt__, __ge__) silently returns False for non-ObjectPath operands, which violates the expected total ordering contract (e.g. both a < 42 and a >= 42 would return False).
I've fixed this by returning NotImplemented instead, which is the Pythonic way to signal unsupported operand types — Python's comparison protocol will then raise a proper TypeError.
I've also added a comprehensive ObjectPathTest class to test_catalog.py covering:
- Basic property access (get_database_name, get_object_name, get_full_name, __str__, from_string)
- Equality and hashing (including use as dict keys and in sets)
- All comparison operators (happy paths with same/different databases and object names, sorting)
- Edge cases: comparisons against int, str, float, None, list, dict — all now correctly raise TypeError
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39195][Table SQL/API] ObjectPath should implement Comparable [flink]
Posted by "JunRuiLee (via GitHub)" <gi...@apache.org>.
JunRuiLee merged PR #27728:
URL: https://github.com/apache/flink/pull/27728
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39195][Table SQL/API] ObjectPath should implement Comparable [flink]
Posted by "rionmonster (via GitHub)" <gi...@apache.org>.
rionmonster commented on code in PR #27728:
URL: https://github.com/apache/flink/pull/27728#discussion_r2893760960
##########
flink-python/pyflink/table/catalog.py:
##########
@@ -1251,6 +1251,21 @@ def get_object_name(self) -> str:
def get_full_name(self) -> str:
return self._j_object_path.getFullName()
+ def compare_to(self, other: 'ObjectPath') -> int:
Review Comment:
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`).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39195][Table SQL/API] ObjectPath should implement Comparable [flink]
Posted by "flinkbot (via GitHub)" <gi...@apache.org>.
flinkbot commented on PR #27728:
URL: https://github.com/apache/flink/pull/27728#issuecomment-3989237436
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "2e1efbd6e2130099a5112a0d48f44f5a74696729",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "2e1efbd6e2130099a5112a0d48f44f5a74696729",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 2e1efbd6e2130099a5112a0d48f44f5a74696729 UNKNOWN
<details>
<summary>Bot commands</summary>
The @flinkbot bot supports the following commands:
- `@flinkbot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39195][Table SQL/API] ObjectPath should implement Comparable [flink]
Posted by "rionmonster (via GitHub)" <gi...@apache.org>.
rionmonster commented on code in PR #27728:
URL: https://github.com/apache/flink/pull/27728#discussion_r2893760960
##########
flink-python/pyflink/table/catalog.py:
##########
@@ -1251,6 +1251,21 @@ def get_object_name(self) -> str:
def get_full_name(self) -> str:
return self._j_object_path.getFullName()
+ def compare_to(self, other: 'ObjectPath') -> int:
Review Comment:
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).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [FLINK-39195][Table SQL/API] ObjectPath should implement Comparable [flink]
Posted by "rionmonster (via GitHub)" <gi...@apache.org>.
rionmonster commented on code in PR #27728:
URL: https://github.com/apache/flink/pull/27728#discussion_r2893760960
##########
flink-python/pyflink/table/catalog.py:
##########
@@ -1251,6 +1251,21 @@ def get_object_name(self) -> str:
def get_full_name(self) -> str:
return self._j_object_path.getFullName()
+ def compare_to(self, other: 'ObjectPath') -> int:
Review Comment:
We may want to consider adding a series of 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`).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org