Github user jackylk commented on a diff in the pull request:

    https://github.com/apache/carbondata/pull/1953#discussion_r170003522
  
    --- Diff: 
processing/src/main/java/org/apache/carbondata/processing/loading/DataLoadProcessBuilder.java
 ---
    @@ -231,4 +238,71 @@ public static CarbonDataLoadConfiguration 
createConfiguration(CarbonLoadModel lo
         return configuration;
       }
     
    +  /**
    +   * set sort column info in configuration
    +   * @param carbonTable carbon table
    +   * @param loadModel load model
    +   * @param configuration configuration
    +   */
    +  private static void setSortColumnInfo(CarbonTable carbonTable, 
CarbonLoadModel loadModel,
    +      CarbonDataLoadConfiguration configuration) {
    +    List<String> sortCols = 
carbonTable.getSortColumns(carbonTable.getTableName());
    +    SortScopeOptions.SortScope sortScope = 
SortScopeOptions.getSortScope(loadModel.getSortScope());
    +    if (!SortScopeOptions.SortScope.LOCAL_SORT.equals(sortScope)
    +        || sortCols.size() == 0
    +        || StringUtils.isBlank(loadModel.getSortColumnsBoundsStr())) {
    +      if (!StringUtils.isBlank(loadModel.getSortColumnsBoundsStr())) {
    +        LOGGER.warn("sort column bounds will be ignored");
    +      }
    +
    +      configuration.setSortColumnRangeInfo(null);
    +      return;
    +    }
    +    // column index for sort columns
    +    int[] sortColIndex = new int[sortCols.size()];
    +    boolean[] isSortColNoDict = new boolean[sortCols.size()];
    +
    +    DataField[] outFields = configuration.getDataFields();
    +    int j = 0;
    +    boolean columnExist;
    +    for (String sortCol : sortCols) {
    +      columnExist = false;
    +
    +      for (int i = 0; !columnExist && i < outFields.length; i++) {
    +        if 
(outFields[i].getColumn().getColName().equalsIgnoreCase(sortCol)) {
    +          columnExist = true;
    +
    +          sortColIndex[j] = i;
    +          isSortColNoDict[j] = !outFields[i].hasDictionaryEncoding();
    +          j++;
    +        }
    +      }
    +
    +      if (!columnExist) {
    +        throw new RuntimeException("Field " + sortCol + " does not 
exist.");
    --- End diff --
    
    It  is better to use DataLoadingException


---

Reply via email to