Search in sources :

Example 1 with DictionaryGenerationException

use of org.apache.carbondata.core.devapi.DictionaryGenerationException in project carbondata by apache.

the class DictionaryFieldConverterImpl method convert.

@Override
public void convert(CarbonRow row, BadRecordLogHolder logHolder) throws CarbonDataLoadingException {
    try {
        String parsedValue = null;
        String dimensionValue = row.getString(index);
        if (dimensionValue == null || dimensionValue.equals(nullFormat)) {
            parsedValue = CarbonCommonConstants.MEMBER_DEFAULT_VAL;
        } else {
            parsedValue = DataTypeUtil.parseValue(dimensionValue, carbonDimension);
        }
        if (null == parsedValue) {
            if ((dimensionValue.length() > 0) || (dimensionValue.length() == 0 && isEmptyBadRecord)) {
                String dataType = carbonDimension.getDataType().getName();
                logHolder.setReason("The value " + " \"" + dimensionValue + "\"" + " with column name " + carbonDimension.getColName() + " and column data type " + dataType + " is not a valid " + dataType + " type.");
            }
            row.update(CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY, index);
        } else {
            row.update(dictionaryGenerator.getOrGenerateKey(parsedValue), index);
        }
    } catch (DictionaryGenerationException e) {
        throw new CarbonDataLoadingException(e);
    }
}
Also used : CarbonDataLoadingException(org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException) DictionaryGenerationException(org.apache.carbondata.core.devapi.DictionaryGenerationException)

Example 2 with DictionaryGenerationException

use of org.apache.carbondata.core.devapi.DictionaryGenerationException in project carbondata by apache.

the class DictionaryFieldConverterImpl method convert.

@Override
public void convert(CarbonRow row, BadRecordLogHolder logHolder) throws CarbonDataLoadingException {
    try {
        String parsedValue = null;
        String dimensionValue = row.getString(index);
        if (dimensionValue == null || dimensionValue.equals(nullFormat)) {
            parsedValue = CarbonCommonConstants.MEMBER_DEFAULT_VAL;
        } else {
            parsedValue = DataTypeUtil.parseValue(dimensionValue, carbonDimension);
        }
        if (null == parsedValue) {
            if ((dimensionValue.length() > 0) || (dimensionValue.length() == 0 && isEmptyBadRecord)) {
                String message = logHolder.getColumnMessageMap().get(carbonDimension.getColName());
                if (null == message) {
                    message = CarbonDataProcessorUtil.prepareFailureReason(carbonDimension.getColName(), carbonDimension.getDataType());
                    logHolder.getColumnMessageMap().put(carbonDimension.getColName(), message);
                }
                logHolder.setReason(message);
            }
            row.update(CarbonCommonConstants.MEMBER_DEFAULT_VAL_SURROGATE_KEY, index);
        } else {
            row.update(dictionaryGenerator.getOrGenerateKey(parsedValue), index);
        }
    } catch (DictionaryGenerationException e) {
        throw new CarbonDataLoadingException(e);
    }
}
Also used : CarbonDataLoadingException(org.apache.carbondata.processing.loading.exception.CarbonDataLoadingException) DictionaryGenerationException(org.apache.carbondata.core.devapi.DictionaryGenerationException)

Aggregations

DictionaryGenerationException (org.apache.carbondata.core.devapi.DictionaryGenerationException)2 CarbonDataLoadingException (org.apache.carbondata.processing.loading.exception.CarbonDataLoadingException)1 CarbonDataLoadingException (org.apache.carbondata.processing.newflow.exception.CarbonDataLoadingException)1