-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
NIFI-11858 Configurable Column Name Normalization in PutDatabaseRecord and UpdateDatabaseTable #9382
Open
ravinarayansingh
wants to merge
9
commits into
apache:main
Choose a base branch
from
ravinarayansingh:NIFI-11858-clean
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
NIFI-11858 Configurable Column Name Normalization in PutDatabaseRecord and UpdateDatabaseTable #9382
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1a28559
cleaned and required changes for https://github.com/apache/nifi/pull…
ravinarayansingh e33343b
Merge branch 'apache:main' into NIFI-11858-clean
ravinarayansingh 2e017bd
updated the description to reflect uppercase conversion of column nam…
ravinarayansingh acc1546
Merge branch 'apache:main' into NIFI-11858-clean
ravinarayansingh 57bb76b
cleaned and required changes for https://github.com/apache/nifi/pull…
ravinarayansingh 9ecf9da
updated the description to reflect uppercase conversion of column nam…
ravinarayansingh 55a762f
added example for REMOVE_ALL_SPECIAL_CHAR and PATTERN
ravinarayansingh bbc560f
Merge remote-tracking branch 'origin/NIFI-11858-clean' into NIFI-1185…
ravinarayansingh 7580ab3
Merge branch 'apache:main' into NIFI-11858-clean
ravinarayansingh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
206 changes: 122 additions & 84 deletions
206
...ndard-processors/src/main/java/org/apache/nifi/processors/standard/PutDatabaseRecord.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...ndard-processors/src/main/java/org/apache/nifi/processors/standard/db/NameNormalizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.nifi.processors.standard.db; | ||
|
||
public interface NameNormalizer { | ||
|
||
String getNormalizedName(String colName); | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
...rocessors/src/main/java/org/apache/nifi/processors/standard/db/NameNormalizerFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.nifi.processors.standard.db; | ||
|
||
import org.apache.nifi.processors.standard.db.impl.PatternNormalizer; | ||
import org.apache.nifi.processors.standard.db.impl.RemoveAllSpecialCharNormalizer; | ||
import org.apache.nifi.processors.standard.db.impl.RemoveSpaceNormalizer; | ||
import org.apache.nifi.processors.standard.db.impl.RemoveUnderscoreAndSpaceNormalizer; | ||
import org.apache.nifi.processors.standard.db.impl.RemoveUnderscoreNormalizer; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
public class NameNormalizerFactory { | ||
public static NameNormalizer getNormalizer(TranslationStrategy strategy, Pattern regex) { | ||
|
||
return switch (strategy) { | ||
case REMOVE_UNDERSCORE -> new RemoveUnderscoreNormalizer(); | ||
case REMOVE_SPACE -> new RemoveSpaceNormalizer(); | ||
case REMOVE_UNDERSCORE_AND_SPACE -> new RemoveUnderscoreAndSpaceNormalizer(); | ||
case REMOVE_ALL_SPECIAL_CHAR -> new RemoveAllSpecialCharNormalizer(); | ||
case PATTERN -> new PatternNormalizer(regex); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...-processors/src/main/java/org/apache/nifi/processors/standard/db/TranslationStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.nifi.processors.standard.db; | ||
|
||
import org.apache.nifi.components.DescribedValue; | ||
|
||
/** | ||
* Enumeration of supported Database column name Translation Strategies | ||
*/ | ||
public enum TranslationStrategy implements DescribedValue { | ||
REMOVE_UNDERSCORE("Remove Underscore", | ||
"Underscores '_' will be removed from column names Ex: 'Pics_1_23' becomes 'PICS123'"), | ||
REMOVE_SPACE("Remove Space", | ||
"Spaces will be removed from column names Ex. 'User Name' becomes 'USERNAME'"), | ||
REMOVE_UNDERSCORE_AND_SPACE("Remove Underscores and Spaces", | ||
"Spaces and Underscores will be removed from column names Ex. 'User_1 Name' becomes 'USER1NAME'"), | ||
REMOVE_ALL_SPECIAL_CHAR("Remove Regular Expression Characters", | ||
"Remove Regular Expression Characters"), | ||
PATTERN("Regular Expression", | ||
"Remove characters matching this Regular Expression from the column names"); | ||
private final String displayName; | ||
private final String description; | ||
|
||
TranslationStrategy(String displayName, String description) { | ||
this.displayName = displayName; | ||
this.description = description; | ||
} | ||
|
||
@Override | ||
public String getValue() { | ||
return name(); | ||
} | ||
|
||
@Override | ||
public String getDisplayName() { | ||
return displayName; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return description; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...ocessors/src/main/java/org/apache/nifi/processors/standard/db/impl/PatternNormalizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.nifi.processors.standard.db.impl; | ||
|
||
import org.apache.nifi.processors.standard.db.NameNormalizer; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
public class PatternNormalizer implements NameNormalizer { | ||
private final Pattern pattern; | ||
|
||
public PatternNormalizer(Pattern pattern) { | ||
this.pattern = pattern; | ||
} | ||
|
||
@Override | ||
public String getNormalizedName(String colName) { | ||
|
||
if (pattern == null) { | ||
return colName; | ||
} else { | ||
return pattern.matcher(colName).replaceAll(""); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you include examples for the two Regex choices? They are the most complex so the more and clearer the documentation the better. After that I'm good to merge!
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.
hi @mattyb149
I have added example . please have a look