Github user sounakr commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2347#discussion_r191398287
--- Diff:
processing/src/main/java/org/apache/carbondata/processing/datatypes/PrimitiveDataType.java
---
@@ -316,15 +321,32 @@ public int getSurrogateIndex() {
if (!this.carbonDimension.getUseActualData()) {
byte[] value = null;
if (isDirectDictionary) {
- int surrogateKey =
dictionaryGenerator.getOrGenerateKey(parsedValue);
+ int surrogateKey;
+ if (dictionaryGenerator instanceof DirectDictionary
+ && input instanceof Long) {
+ surrogateKey = ((DirectDictionary)
dictionaryGenerator).generateKey((long) input);
+ } else {
+ surrogateKey =
dictionaryGenerator.getOrGenerateKey(parsedValue);
+ }
if (surrogateKey ==
CarbonCommonConstants.INVALID_SURROGATE_KEY) {
value = new byte[0];
} else {
value = ByteUtil.toBytes(surrogateKey);
}
} else {
- value =
DataTypeUtil.getBytesBasedOnDataTypeForNoDictionaryColumn(parsedValue,
- this.carbonDimension.getDataType(), dateFormat);
+ if (this.carbonDimension.getDataType().equals(DataTypes.DATE)
+ ||
this.carbonDimension.getDataType().equals(DataTypes.TIMESTAMP)
+ && input instanceof Long) {
--- End diff --
Add a comment on which case input will be long
---