morningman commented on a change in pull request #7149:
URL: https://github.com/apache/incubator-doris/pull/7149#discussion_r758132617



##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
##########
@@ -197,6 +199,12 @@ public boolean dynamicPartitionExists() {
                 && tableProperty.getDynamicPartitionProperty().isExist();
     }
 
+    public boolean isZOrderSort() {
+        return tableProperty != null
+                && tableProperty.getDataSortInfo() != null
+                && tableProperty.getDataSortInfo().getSortType() != 
TSortType.LEXICAL;

Review comment:
       ```suggestion
                   && tableProperty.getDataSortInfo().getSortType() == 
TSortType.ZORDER;
   ```
   
   So that we don't need to modify it if we add some other sort type later.

##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/TableProperty.java
##########
@@ -137,6 +151,11 @@ public void modifyTableProperties(Map<String, String> 
modifyProperties) {
         properties.putAll(modifyProperties);
     }
 
+    public void modifyTableProperties(DataSortInfo dataSortInfo) {

Review comment:
       Not same, the origin 2 `modifyTableProperties()` method pass the 
`key-value`, which means it can modify any of table properties.
   But here you just want to modify the data sort info.

##########
File path: fe/fe-core/src/main/java/org/apache/doris/analysis/DataSortInfo.java
##########
@@ -0,0 +1,104 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.analysis;
+
+import org.apache.doris.common.io.Writable;
+import org.apache.doris.thrift.TSortType;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Map;
+
+public class DataSortInfo implements Writable {
+    public static final String DATA_SORT_PROPERTY_PREFIX = "data_sort";
+    public static final String DATA_SORT_TYPE = "data_sort.sort_type";
+    public static final String DATA_SORT_COL_NUM = "data_sort.col_num";
+
+    private TSortType sortType;
+    private int colNum;
+
+    public DataSortInfo() {
+
+    }
+
+    public DataSortInfo(Map<String, String> properties) {
+        if (properties != null && !properties.isEmpty()) {
+            if (properties.get(DATA_SORT_TYPE).equalsIgnoreCase("ZORDER")) {
+                this.sortType = TSortType.ZORDER;
+            } else {
+                this.sortType = TSortType.LEXICAL;
+            }
+            this.colNum = Integer.parseInt(properties.get(DATA_SORT_COL_NUM));
+        }
+    }
+
+    public DataSortInfo (TSortType sortType, int colNum) {
+        this.sortType = sortType;
+        this.colNum = colNum;
+    }
+
+    public TSortType getSortType() {
+        return sortType;
+    }
+
+    public void setSortType(TSortType sortType) {
+        this.sortType = sortType;
+    }
+
+    public int getColNum() {
+        return colNum;
+    }
+
+    public void setColNum(int colNum) {
+        this.colNum = colNum;
+    }
+
+    @Override
+    public void write(DataOutput out) throws IOException {
+        out.writeInt(sortType.getValue());
+        out.writeInt(colNum);
+    }
+
+    public void readFields(DataInput in) throws IOException {
+        this.sortType = TSortType.findByValue(in.readInt());
+        this.colNum = in.readInt();
+    }
+
+    public static DataSortInfo read(DataInput in) throws IOException {
+        TSortType sortType = TSortType.findByValue(in.readInt());
+        int colNum = in.readInt();
+        return new DataSortInfo(sortType, colNum);
+    }
+
+    public boolean equals(DataSortInfo dataSortInfo) {
+        if (this.sortType != dataSortInfo.sortType) {
+            return false;
+        }
+        if (this.colNum != dataSortInfo.colNum) {
+            return false;
+        }
+        return true;
+    }
+
+    public String getProperties() {

Review comment:
       Oh, So I think we should change the dynamic partition too...
   It is more like toString() or toSql()

##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTable.java
##########
@@ -1714,6 +1729,13 @@ public TStorageFormat getStorageFormat() {
         return tableProperty.getStorageFormat();
     }
 
+    public DataSortInfo getDataSortInfo() {
+        if (tableProperty == null) {
+            return new DataSortInfo();

Review comment:
       Better assign the default value to the fields of `DataSortInfo`, so that 
we can make this return more semantically accurate




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to