rbhive
rbhive copied to clipboard
Hive metastore types in global namespace
The classes defined in hive_metastore_types.rb
are created directly in the global namespace, not in a specific module and they are prone to class name collisions because of this.
For example, in my project my Role
model is conflicting with the Role
class defined by rbhive. There are other very generic names in this file that could also cause collisions, like Type
and Version
.
Can you put these classes inside a module? Is there any workaround in the meantime?
Yep, it's totally possible to namespace them; in fact, I thought I had namespaced all the autogenerated code. It requires regenerating the Thrift code.
I've been meaning to change the namespacing to be more logical - let me look at this and cut a new gem in the next day or so.
Thanks for the quick reply. I figured this was more complex than just wrapping the code in a module otherwise I would have sent a pull request.
For a workaround I'll just rename my model temporarily in my project's feature branch until you have the new gem out.
Andy, We are having the same problem with few classes. Did you get a chance to namespace them?
Andy! Why not check in the IDL code so that someone else can fix this? We also need a fix and would happily patch and share, but without the .thrift files, we cannot regenerate the files. Any update on this?
The IDL code is not owned by me or written by me. It's the property of the Hive project, and you can find the IDL files there if you want to take a crack at regenerating the classes. I've been too busy with other things to do this, as regenerating the code is pretty painful (Thrift is hard to install).
I will try to have a look at it today.
I tried yesterday. I did the following :
- Got the latest Thrift source and built it on my Mac (1.0.0-dev) - This worked with some hacks.
- Got the latest Hive source and built it, including code-generating Thrift IDL. This failed after serde and metastore thrift was built, so I was able to get the classes we depend on built and copied over to my local rbhive working directory
- I had to make some manual changes (e.g. converting "require" to "require_relative"). Unfortunately, though the Version issue is fixed in one class, I still found it was not fixed in hive_metastore_types.rb, hence some more work needs to be done on the hive side to fix the issue.
II would say it's worth someone else trying this to validate my findings.
Another rather generic class name I have problems with it Database
.