forked from delta-io/delta
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flink Delta Source PR 12.1 - DeltaSource::option(...) value type conv…
…ersion - bug fix and more tests (delta-io#365) * PR ColumnsFromDeltaLog - get table schema from Delta Log. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR ColumnsFromDeltaLog - get table schema from Delta Log. Using SnapshotVersion in Enumerator factory. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 10.1 ColumnsFromDeltaLog_Tests - extra test for Delta table Schema discovery. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 11 - Partition support using Delta Log Metadata Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 10 - Changes after code review. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 10.1 - Added Delta - Flink - Delta type conversion test. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 10 ColumnsFromDeltaLog - Prevent user to set internal options via source builder. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 10 ColumnsFromDeltaLog - Changes after code review Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 10.1 Adding tests Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 10.1 Adding tests Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 11 Partition Support Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 12 Option validation - Get BATCH_SIZE for Format builder from Source options. Add validation for option names and values. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 12 Option validation - Get BATCH_SIZE for Format builder from Source options. Add validation for option names and values. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 10.1 Changes after code review. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 10.1 Added tests. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 11 Test fix after merge Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 10.1 cleanup. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 11 Fix after merge conflicts from master. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 11 Make RowDataFormat constructor package protected. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 11 Changes after Code review Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 12 Fix compilation error after merge from base branch. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 12 - Validation for Inapplicable Option Used + tests. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 12 - Javadocs Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 12 - Adding option type safety Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 12 - Adding option type safety tests Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 11 - Changes after code review. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 11 - Changes after code review. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 11 - Changes after code review. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 11 - Changes after code review. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 11 - Changes after code review. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 12 - test for options Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 12 - Type conversion for Timestamp based options and adding tests. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 12 - Change TODO's from PR 12 to PR 12.1 Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 12.1 - Option validation, throw DeltaSourceValidationException + tests. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 12 - changes after code review Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 12.1 - Validation for option setting and more tests. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 12.1 - Validation for option setting and more tests. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 12.1 - Validation for set options - BugFixes, tests, changes after code review. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> * PR 12.1 - Changes after code review. Signed-off-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com> Co-authored-by: Krzysztof Chmielewski <krzysztof.chmielewski@getindata.com>
- Loading branch information
1 parent
e151fde
commit 153993d
Showing
17 changed files
with
770 additions
and
68 deletions.
There are no files selected for viewing
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
4 changes: 2 additions & 2 deletions
4
flink/src/main/java/io/delta/flink/source/internal/builder/BaseOptionTypeConverter.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
55 changes: 55 additions & 0 deletions
55
flink/src/main/java/io/delta/flink/source/internal/builder/BooleanOptionTypeConverter.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,55 @@ | ||
package io.delta.flink.source.internal.builder; | ||
|
||
/** | ||
* Implementation of {@link OptionTypeConverter} that validates values for | ||
* {@link DeltaConfigOption} with type Boolean. | ||
*/ | ||
public class BooleanOptionTypeConverter extends BaseOptionTypeConverter<Boolean> { | ||
|
||
/** | ||
* Converts String values for {@link DeltaConfigOption} with Boolean value type. | ||
* Strings "true" and "false" will be converted to Boolean true and false values. | ||
* | ||
* @param desiredOption The {@link DeltaConfigOption} instance we want to do the conversion | ||
* for. | ||
* @param valueToConvert String value to convert. | ||
* @return A String representing Boolean value for given {@code valueToConvert} parameter. | ||
* @throws IllegalArgumentException in case of conversion failure. | ||
*/ | ||
@Override | ||
@SuppressWarnings("unchecked") | ||
public <T> T convertType(DeltaConfigOption<T> desiredOption, String valueToConvert) { | ||
Class<T> decoratedType = desiredOption.getValueType(); | ||
OptionType type = OptionType.instanceFrom(decoratedType); | ||
|
||
if (type == OptionType.BOOLEAN) { | ||
|
||
if ("true".equalsIgnoreCase(valueToConvert) || | ||
"false".equalsIgnoreCase(valueToConvert)) { | ||
return (T) Boolean.valueOf(valueToConvert); | ||
} | ||
|
||
throw invalidValueException(desiredOption.key(), valueToConvert); | ||
} | ||
|
||
throw new IllegalArgumentException( | ||
String.format( | ||
"BooleanOptionTypeConverter used with a incompatible DeltaConfigOption " | ||
+ "option type. This converter must be used only for " | ||
+ "DeltaConfigOption::Boolean however it was used for '%s' with option '%s'", | ||
desiredOption.getValueType(), desiredOption.key()) | ||
); | ||
} | ||
|
||
private IllegalArgumentException invalidValueException( | ||
String optionName, | ||
String valueToConvert) { | ||
return new IllegalArgumentException( | ||
String.format( | ||
"Illegal value used for [%s] option. Expected values " | ||
+ "\"true\" or \"false\" keywords (case insensitive) or boolean true," | ||
+ " false values. Used value was [%s]", | ||
optionName, valueToConvert) | ||
); | ||
} | ||
} |
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
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
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
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
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
Oops, something went wrong.