Skip to content
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

Open
wants to merge 2 commits into
base: branch-2.3-criteo
Choose a base branch
from
Open

EXTERNAL property overrides tableType #115

wants to merge 2 commits into from

Conversation

mliroz
Copy link

@mliroz mliroz commented Oct 27, 2020

A table is external in the following two cases:

  • Its tableType is EXTERNAL_TABLE and property EXTERNAL is not false
  • Property EXTERNAL is true

This will allow to alter tables through DDL statements, which was not possible with previous behaviors.

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));

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?

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 ... 

Copy link
Author

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

Copy link

@antonlin1 antonlin1 left a 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());

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);

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));
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants