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

Add custom schema handling logic to directives that rename columns #649

Merged
merged 1 commit into from
Aug 17, 2023

Conversation

vanathi-g
Copy link
Contributor

Changes

  • Override getOutputSchema method in rename, set-headers, swap, cleanse-columns directives
  • All of these perform column renames, hence the necessary column schemas are also modified to avoid generating a new schema for renamed columns

Base automatically changed from add-schema to develop July 25, 2023 05:14
@vanathi-g vanathi-g force-pushed the schema-directive-changes branch 2 times, most recently from 6f3642f to 0477f5c Compare July 25, 2023 10:52
List<Schema.Field> fields = new ArrayList<>(context.getInputSchema().getFields());
for (int i = 0; i < columns.size(); i++) {
Schema.Field existing = fields.remove(i);
fields.add(i, Schema.Field.of(columns.get(i), existing.getSchema()));
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Will there be a case where number of elements in columns are greater than number of elements in inputSchema? in that case, existing.getSchema() might throw a NullPointerException?
  2. Why are we removing and adding elements to existing input schema rather than creating a new list? if we can, then we should for readability.

@vanathi-g vanathi-g added the build Triggers unit test build label Aug 9, 2023
@vanathi-g vanathi-g merged commit 99403b1 into develop Aug 17, 2023
3 checks passed
@vanathi-g vanathi-g deleted the schema-directive-changes branch August 17, 2023 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Triggers unit test build
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants