-
Notifications
You must be signed in to change notification settings - Fork 18
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
EXTERNAL property overrides tableType #115
base: branch-2.3-criteo
Are you sure you want to change the base?
Conversation
A table is external in the following two cases: - It is declared as EXTERNAL_TABLE and EXTERNAL is not false - EXTERNAL is true This will allow to alter tables through DDL statements, which was not possible with previous behaviors.
else { | ||
String externalParam = params.get(EXTERNAL_TABLE_PROP); | ||
if (externalParam != null) { | ||
return Boolean.parseBoolean(params.get(EXTERNAL_TABLE_PROP)); |
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.
Nit: swap out params.get(EXTERNAL_TABLE_PROP)
for externalParam
?
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.
Nit 2: what about having flat if-case
here?
if (params == null) {
...
} else if (params.get(EXTERNAL_TABLE_PROP) == null ) {
...
} 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.
Ok for first comment. For the second if I actually follow the previous style it would be more sth like this:
if (params == null) {
return xxx
}
String externalParam = params.get(EXTERNAL_TABLE_PROP);
if (externalParams != null) {
return yyy;
}
return zzz;
In any case, both cannot be done at the same time
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.
Actually those previous nitpicks are totally not blocking. I should have put approved
@@ -1472,22 +1472,25 @@ public static FieldSchema getFieldSchemaFromTypeInfo(String fieldName, | |||
"generated by TypeInfoUtils.getFieldSchemaFromTypeInfo"); | |||
} | |||
|
|||
private static boolean isTableTypeExternal(Table table) { | |||
String tableType = table.getTableType(); | |||
return tableType != null && tableType.equals(TableType.EXTERNAL_TABLE.name()); |
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.
Another way to do this is to return:
TableType.EXTERNAL_TABLE.name().equals(table.getTableType())
return isTableTypeExternal(table); | ||
} | ||
else { | ||
String externalParam = params.get(EXTERNAL_TABLE_PROP); |
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.
shorter version:
if (params == null || !params.containsKey(EXTERNAL_TABLE_PROP)) {
return isTableTypeExternal(table);
} else {
return Boolean.parseBoolean(params.get(EXTERNAL_TABLE_PROP));
}
A table is external in the following two cases:
tableType
isEXTERNAL_TABLE
and propertyEXTERNAL
is not falseEXTERNAL
is trueThis will allow to alter tables through DDL statements, which was not possible with previous behaviors.