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

Validate timeColumnName when adding/updating schema/tableConfig #5966

Merged
merged 3 commits into from
Sep 10, 2020

Conversation

npawar
Copy link
Contributor

@npawar npawar commented Sep 3, 2020

Description

#5915
Add validation to check that timeColumnName is in sync across the table config and schema.

Cases

  • Adding/updating tableConfig - Find associated schema (using rawTableName or from validationConfig.getSchemaName). Check that timeColumnName is present in schema. For OFFLINE, it is possible that timeColumnName/schema is null.
  • Adding/updating schema - Find associated table configs (schemaName_OFFLINE and schemaName_REALTIME) Check timeColumnName used in all associated tableConfigs also exists in schema.

Corner case
If tableConfig has been created with a schemaName != rawTableName, then we will not be able to validate during schema add/upload.

Release Notes

After this change,

  1. uploading a tableConfig with timeColumnName not present in schema will be disallowed (provided schema already uploaded)
  2. uploading schema with timeColumnName not present in the schema will be disallowed (provided schemaName = tableName)

@mcvsubbu
Copy link
Contributor

mcvsubbu commented Sep 3, 2020

We do allow to have tables without a schema. I have not had the time to go through this fully, but do you account for the fact that a (offline) table may not have a schema at all?

@npawar
Copy link
Contributor Author

npawar commented Sep 4, 2020

We do allow to have tables without a schema. I have not had the time to go through this fully, but do you account for the fact that a (offline) table may not have a schema at all?

Yes, I have accounted for offline table not having schema at all. I've put in the description all the cases it covers, and the case we miss out

Copy link
Contributor

@icefury71 icefury71 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments

// empty list
List<TableConfig> tableConfigs = new ArrayList<>();
Schema schema = new Schema.SchemaBuilder().setSchemaName(TABLE_NAME).build();
SchemaUtils.validate(schema, tableConfigs);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: wrap with try-catch for future proofing ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you mean a case where the schema becomes invalid, but we pass the test anyway because of not having a try-catch?
Just to be sure, I tried this out. The test fails if there's any exception in the should-pass cases.
Lmk if you were referring to something else.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant catching exception and explicitly 'fail'ing. It's fine though - just a nit.

// offline table
// null timeColumnName
TableConfig tableConfig = new TableConfigBuilder(TableType.OFFLINE).setTableName(TABLE_NAME).build();
SchemaUtils.validate(schema, Lists.newArrayList(tableConfig));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Contributor

@Jackie-Jiang Jackie-Jiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with minor comments

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.

4 participants