forward3d / rbhive

Ruby gem for querying Apache Hive
http://www.forward3d.com
MIT License
98 stars 74 forks source link

Hive metastore types in global namespace #20

Open JamesMcMahon opened 10 years ago

JamesMcMahon commented 10 years ago

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?

andytinycat commented 10 years ago

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.

JamesMcMahon commented 10 years ago

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.

anilpeechara commented 9 years ago

Andy, We are having the same problem with few classes. Did you get a chance to namespace them?

r39132 commented 9 years ago

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?

andytinycat commented 9 years ago

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.

r39132 commented 9 years ago

I tried yesterday. I did the following :

  1. Got the latest Thrift source and built it on my Mac (1.0.0-dev) - This worked with some hacks.
  2. 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
  3. 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.

pointlessone commented 5 years ago

Another rather generic class name I have problems with it Database.