This is an automated email from the ASF dual-hosted git repository.
jshao pushed a commit to branch branch-0.9
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/branch-0.9 by this push:
new d63de56b9e [#5362] fix(client-python): fix wrong Gravitino version
(#6968)
d63de56b9e is described below
commit d63de56b9ed4ba44cead93e757d015828cdb53ad
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Apr 16 19:08:28 2025 +0800
[#5362] fix(client-python): fix wrong Gravitino version (#6968)
### What changes were proposed in this pull request?
In current implementation of `GravitinoVersion.__gt__`, we don't handle
the case
when `version1.minor < version2.minor and version1.patch >
version.patch`,
i.e. this will cause `0.6.1` greater than `0.7.0`.
### Why are the changes needed?
Bug fix.
Fix: #5362
### Does this PR introduce _any_ user-facing change?
Yes, bug fixes.
### How was this patch tested?
By `TestGravitinoVersion.test_version_compare`
Co-authored-by: Eric Chang <[email protected]>
---
clients/client-python/gravitino/client/gravitino_version.py | 10 +++-------
.../client-python/tests/unittests/test_gravitino_version.py | 7 +++++++
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/clients/client-python/gravitino/client/gravitino_version.py
b/clients/client-python/gravitino/client/gravitino_version.py
index 8a99b13e37..6919643fcf 100644
--- a/clients/client-python/gravitino/client/gravitino_version.py
+++ b/clients/client-python/gravitino/client/gravitino_version.py
@@ -61,13 +61,9 @@ class GravitinoVersion(VersionDTO):
raise GravitinoRuntimeException(
f"{GravitinoVersion.__name__} can't compare with
{other.__class__.__name__}"
)
- if self.major > other.major:
- return True
- if self.minor > other.minor:
- return True
- if self.patch > other.patch:
- return True
- return False
+ v1 = (self.major, self.minor, self.patch)
+ v2 = (other.major, other.minor, other.patch)
+ return v1 > v2
def __eq__(self, other) -> bool:
if not isinstance(other, GravitinoVersion):
diff --git a/clients/client-python/tests/unittests/test_gravitino_version.py
b/clients/client-python/tests/unittests/test_gravitino_version.py
index 12f47f43f3..c0f3125e20 100644
--- a/clients/client-python/tests/unittests/test_gravitino_version.py
+++ b/clients/client-python/tests/unittests/test_gravitino_version.py
@@ -81,6 +81,13 @@ class TestGravitinoVersion(unittest.TestCase):
self.assertGreater(version1, version2)
+ # version1.minor < version2.minor and version1.patch > version.patch
+ version1 = GravitinoVersion(VersionDTO("0.6.1", "2023-01-01",
"1234567"))
+ version2 = GravitinoVersion(VersionDTO("0.7.0", "2023-01-01",
"1234567"))
+
+ self.assertFalse(version1 > version2)
+ self.assertGreater(version2, version1)
+
# test equal with suffix
version1 = GravitinoVersion(
VersionDTO("0.6.0-SNAPSHOT", "2023-01-01", "1234567")