diff --git a/core-dictionary/src/main/java/org/apache/kylin/dict/lookup/SnapshotTable.java b/core-dictionary/src/main/java/org/apache/kylin/dict/lookup/SnapshotTable.java old mode 100644 new mode 100755 index b2306b2..5815f60 --- a/core-dictionary/src/main/java/org/apache/kylin/dict/lookup/SnapshotTable.java +++ b/core-dictionary/src/main/java/org/apache/kylin/dict/lookup/SnapshotTable.java @@ -35,6 +35,7 @@ import org.apache.kylin.common.util.Dictionary; import org.apache.kylin.dict.StringBytesConverter; import org.apache.kylin.dict.TrieDictionary; import org.apache.kylin.dict.TrieDictionaryBuilder; +import org.apache.kylin.metadata.model.ColumnDesc; import org.apache.kylin.metadata.model.TableDesc; import org.apache.kylin.source.ReadableTable; @@ -80,8 +81,8 @@ public class SnapshotTable extends RootPersistentEntity implements ReadableTable if (row.length <= maxIndex) { throw new IllegalStateException("Bad hive table row, " + tableDesc + " expect " + (maxIndex + 1) + " columns, but got " + Arrays.toString(row)); } - - for (String cell : row) { + for (ColumnDesc column : tableDesc.getColumns()) { + String cell = row[column.getZeroBasedIndex()]; if (cell != null) b.addValue(cell); } @@ -97,9 +98,9 @@ public class SnapshotTable extends RootPersistentEntity implements ReadableTable try { while (reader.next()) { String[] row = reader.getRow(); - int[] rowIndex = new int[row.length]; - for (int i = 0; i < row.length; i++) { - rowIndex[i] = dict.getIdFromValue(row[i]); + int[] rowIndex = new int[tableDesc.getColumnCount()]; + for (ColumnDesc column : tableDesc.getColumns()) { + rowIndex[column.getZeroBasedIndex()] = dict.getIdFromValue(row[column.getZeroBasedIndex()]); } allRowIndices.add(rowIndex); }