https://slatedb.io logo
@criccomini
# general
a
@criccomini https://pypi.org/project/pymetastore/0.4.1/ I know it's not appropriate to ask it in SlateDB channel, but I've encountered a small problem: I have a Python script at work that depends on this
dep
, and I've run into a bug related to Hive views. I found that its maintainer is you, but the GitHub repo seems to no longer exist. I'd like to know if it's no longer maintained? If so, where can I find its source code?
c
Hi! Yep, it's still there and still maintained.
Someone just opened this issue a few weeks ago: https://github.com/criccomini/pymetastore/issues/39
Is it perhaps related to your problem?
a
thanks!
c
Np. @AsukaMilet Any idea what is causing your issue? If so, I can merge patches/release/whatever is needed.
a
I left my Mac at the office; I'll do a review after I get to work tomorrow.
Yes, that's the problem. I've figured out how to fix it, and I'll open a PR as soon as possible.
c
ohh
thank you!!
A patch would be much appreciated. Been a while since I messed with Hive.
c
πŸ”₯
cooking dinner right now. Will merge/release in the next hour or two
🐟 + 🍚 = dinner πŸ˜„
bah.. docker image moved to ghcr.io/criccomini/hive-metastore-standalone:latest
fixing
haha been a while since this CI was run..
K, rebased your branch with fixes. Let's see if we can get the test passing πŸ˜›
@AsukaMilet mind running
pdm style
on it?
nm i'm taking care of it πŸ™‚
a
Wait a moment, I have a meeting to attend.
It seems that
serdeLib info
required to be nonNull during writing; I will be able to fix it quickly after attending company meeting.
c
Thx
Ya the integration test is failing
Seems like a legit failure.. something related to ttypes/thrift stuff
I passed it through Codex and it seems to suggest:
Copy code
β€’ Understood. I reverted the test back to using a null SerDeInfo and updated the code to support it end-to-end without failing.

  What I changed

  - Thrift client normalization
      - pymetastore/hive_metastore/ThriftHiveMetastore.py: send_create_table, send_create_table_with_environment_context, send_create_table_with_constraints
          - If tbl.sd.serdeInfo is None, inject a minimal default SerDeInfo:
              - serializationLib='org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
              - parameters={}
          - This avoids server-side MetaException rejections while letting callers pass None in Python.
  - HMS parsing improvements
      - pymetastore/metastore.py: get_table conversion
          - Accepts completely missing serdeInfo for VIRTUAL_VIEW tables (sets serde=None in StorageFormat).
          - Accepts serdeInfo with missing serializationLib for views and treats it as None.
          - Allows missing serdeInfo.parameters by treating them as {} instead of raising.
      - This ensures our model handles views with null SerDeInfo cleanly.
  - Test fixture
      - tests/integration/test_metastore.py:352
          - Uses serdeInfo=None for the VIRTUAL_VIEW storage descriptor again (as originally intended).

  Why this solves it

  - You can now create a view with serdeInfo=None in tests without tripping the Metastore’s validation, since the client fills a minimal valid SerDeInfo at send time.
  - The HMS wrapper properly tolerates and represents the absence of SerDe info for views.

  How to verify

  - Run: pytest -q tests/integration/test_metastore.py
  - Requires a running Hive Metastore at localhost:9083 (or set HMS_HOST/HMS_PORT).

  If you want, I can also make the same serdeInfo normalization available via an explicit helper in our higher-level API, but with these changes the tests and normal usage
  should already pass.
tl;dr, it uses
lazy.LazySimpleSerDe
if
None
is set.
No idea if that's the right idea, though πŸ˜›
Fyi, pushing this to your branch:
Copy code
index f93dcfa..a8c82d8 100644
--- a/pymetastore/metastore.py
+++ b/pymetastore/metastore.py
@@ -446,13 +446,13 @@ class HMS:
                             raise TypeError(
                                 f"Expected serializationLib to be str, got {type(table.sd.serdeInfo.serializationLib)}"
                             )
-                    else:
+                    elif table.tableType == "VIRTUAL_VIEW":
                         # See #39 and #40 for details
-                        if table.tableType != "VIRTUAL_VIEW":
-                            raise TypeError(
-                                f"Expected serdeInfo to be str, got {type(table.sd.serdeInfo)}"
-                            )
                         serde = None
+                    else:
+                        raise TypeError(
+                            f"Expected serdeInfo to be str, got {type(table.sd.serdeInfo)}"
+                        )
                 else:
                     raise TypeError(
                         f"Expected serdeInfo to be SerDeInfo, got {type(table.sd.serdeInfo)}"
(just seemed like slightly cleaner branch logic)
It appears that the thrift definition, itself, doesn't allow for null SerDeInfos: https://github.com/trinodb/hive-thrift/blob/master/src/main/thrift/hive_metastore.thrift#L389-L425
Table
has
StorageDescriptor sd
which has
SerDeInfo    serdeInfo
K, I reverted the setup_data change back to
serde_info
instead of
None
(and left a comment). https://github.com/criccomini/pymetastore/pull/40/commits/420d69e9c6568116a36d47a67cf7df8a7783b409
Huzzah it passes
a
I know. As I understand, Hive view shouldn't need
serdeInfo
because all its information is stored in the original sql field.
I don't know which SDK our customer is using to write to the Hive. When I connect to HMS via the Hive CLI, the serdeLib column is showing as null.
Thanks for your help.
c
No worries. Based on chatgpt, it sounds like it just depends on the hive metastore implementation being used. Some do support nulls while others don't...
Setting up a release script for it now. It's so old I was doing the releases manually to pypi πŸ˜›
thanks for digging into this!
a
pymetastore supports one of our very important customer. I should thank you for your efforts.🫑
c
woot. released!
0.4.2
LMK if you hit any snags with it