nihal0107 commented on a change in pull request #3865:
URL:
https://github.com/apache/carbondata/pull/3865#discussion_r471232002##########
File path: processing/src/main/java/org/apache/carbondata/processing/datatypes/PrimitiveDataType.java
##########
@@ -330,21 +331,35 @@ public void writeByteArray(Object input, DataOutputStream dataOutputStream,
}
}
+ private byte[] getNullForBytes(byte[] value) {
+ String badRecordAction = CarbonProperties.getInstance()
+ .getProperty(CarbonCommonConstants.CARBON_BAD_RECORDS_ACTION);
+ if (badRecordAction.equalsIgnoreCase(CarbonCommonConstants.FORCE_BAD_RECORD_ACTION)) {
+ if (this.carbonDimension.getDataType() == DataTypes.STRING) {
+ return CarbonCommonConstants.MEMBER_DEFAULT_VAL_ARRAY;
+ } else {
+ return CarbonCommonConstants.EMPTY_BYTE_ARRAY;
+ }
+ }
+ return value;
+ }
+
private void checkAndWriteByteArray(Object input, DataOutputStream dataOutputStream,
BadRecordLogHolder logHolder, Boolean isWithoutConverter, String parsedValue, byte[] value)
throws IOException {
if (isWithoutConverter) {
if (this.carbonDimension.getDataType() == DataTypes.STRING && input instanceof String
&& ((String)input).length() > CarbonCommonConstants.MAX_CHARS_PER_COLUMN_DEFAULT) {
- throw new CarbonDataLoadingException("Dataload failed, String size cannot exceed "
- + CarbonCommonConstants.MAX_CHARS_PER_COLUMN_DEFAULT + " bytes");
+ logHolder.setReason(String.format(CarbonCommonConstants.STRING_LENGTH_EXCEEDED_MESSAGE,
+ input.toString(), this.carbonDimension.getColName()));
+ value = getNullForBytes(value);
}
updateValueToByteStream(dataOutputStream, value);
} else {
if (this.carbonDimension.getDataType() == DataTypes.STRING
&& value.length > CarbonCommonConstants.MAX_CHARS_PER_COLUMN_DEFAULT) {
- throw new CarbonDataLoadingException("Dataload failed, String size cannot exceed "
- + CarbonCommonConstants.MAX_CHARS_PER_COLUMN_DEFAULT + " bytes");
+ logHolder.setReason(String.format(CarbonCommonConstants.STRING_LENGTH_EXCEEDED_MESSAGE,
Review comment:
done.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[hidden email]