-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DAE-145] Change the default values for create table event #62
[DAE-145] Change the default values for create table event #62
Conversation
@@ -34,7 +34,7 @@ def __init__( | |||
""" | |||
self.name = name | |||
self.serialization_lib = serialization_lib | |||
self.parameters = parameters | |||
self.parameters = parameters if parameters else {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would compare it directly to None to avoid overwriting falsy parameters check this SO reply.
Just for information, there is an equivalent form as the one proposed self.parameters = parameters or {}
which some people consider more readable. But I still think it's worth using the {} if parameters is None else parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I'm afraid I didn't get what you suggested Breno. Because python considers None as False in boolean comparisons.
Also if we restrict the comparison to if parameter is None
, we will miss other False values as False, '', 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think it would be better to not overwrite falsy values like False, '' or 0 because it would silently change the values.
If we want to restrict arguments like 0 and '' we can validate the type and raise an exception for the invalid ones but I don't like the idea of mixing this validation with the default argument behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Why? 📖
We've been using the hive-metastore listener to track all DDLs running on the server that generates a payload sent to the Kafka topic in order for the Apache Atlas can read them and create the objects in your ecosystem.
Using the lib we faced a problem with the creation of tables based on Json schema, actually, the creation of the table worked as expected, but the listener could not get the json schema, given the following error:
In the first shot, that error looks like something related to the listener code, but after realizing plenty of tests with many kinds of changes in the listener, I could not find any idea of the reason for this specific error: a mere NullPointer 😞
After that, I tried to get the object created by the listener and did a comparison with the object saved in the hive-metastore database through the hive-metastore client, and I noticed that there were different objects for the same table, so I could see that some default values for TableBuilder and SerdeInfoBuilder were the reason for the specific error above.
What? 🔧
SerdeInfoBuilder
TableBuilder
Type of change 🗄️
How everything was tested? 📏
Ran the create table event with those hard-coded attributes and checked the hive-metastore log that got the json schema.
Checklist 📝