You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by ka...@apache.org on 2020/11/20 01:51:27 UTC

[incubator-doris] branch master updated: Disable the creation of segment v1 table (#4913)

This is an automated email from the ASF dual-hosted git repository.

kangkaisen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new f445ed5  Disable the creation of segment v1 table (#4913)
f445ed5 is described below

commit f445ed5b8aa1e523f95dd698a15d9c4cbe1c6b3f
Author: Zhengguo Yang <ya...@gmail.com>
AuthorDate: Fri Nov 20 09:51:14 2020 +0800

    Disable the creation of segment v1 table (#4913)
---
 .../main/java/org/apache/doris/common/Config.java  |  8 ++++++++
 .../apache/doris/common/util/PropertyAnalyzer.java |  4 ++++
 .../org/apache/doris/alter/AlterJobV2Test.java     |  4 ++++
 .../apache/doris/common/PropertyAnalyzerTest.java  | 23 ++++++++++++++++++++++
 4 files changed, 39 insertions(+)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/Config.java b/fe/fe-core/src/main/java/org/apache/doris/common/Config.java
index 2e6aaee..6560995 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/Config.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/Config.java
@@ -1293,4 +1293,12 @@ public class Config extends ConfigBase {
      */
     @ConfField
     public static String http_api_extra_base_path = "";
+
+    /**
+     * Whether to support the creation of alpha rowset tables.
+     * The default is false and should only be used in emergency situations,
+     * this config should be remove in some future version
+     */
+    @ConfField
+    public static boolean enable_alpha_rowset = false;
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
index dcc3ea0..9b726c6 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
@@ -411,6 +411,10 @@ public class PropertyAnalyzer {
         }
 
         if (storageFormat.equalsIgnoreCase("v1")) {
+            if (!Config.enable_alpha_rowset) {
+                throw new AnalysisException("Storage format V1 has been deprecated since version 0.14," +
+                        " please use V2 instead");
+            }
             return TStorageFormat.V1;
         } else if (storageFormat.equalsIgnoreCase("v2")) {
             return TStorageFormat.V2;
diff --git a/fe/fe-core/src/test/java/org/apache/doris/alter/AlterJobV2Test.java b/fe/fe-core/src/test/java/org/apache/doris/alter/AlterJobV2Test.java
index 0c0e3f4..c0a0266 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/alter/AlterJobV2Test.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/alter/AlterJobV2Test.java
@@ -24,6 +24,7 @@ import org.apache.doris.analysis.ShowAlterStmt;
 import org.apache.doris.catalog.Catalog;
 import org.apache.doris.catalog.Database;
 import org.apache.doris.catalog.OlapTable;
+import org.apache.doris.common.Config;
 import org.apache.doris.common.DdlException;
 import org.apache.doris.common.FeConstants;
 import org.apache.doris.qe.ConnectContext;
@@ -53,6 +54,7 @@ public class AlterJobV2Test {
         FeConstants.runningUnitTest = true;
 
         UtFrameUtils.createMinDorisCluster(runningDir);
+        Config.enable_alpha_rowset = true;
 
         // create connect context
         connectContext = UtFrameUtils.createDefaultCtx();
@@ -128,7 +130,9 @@ public class AlterJobV2Test {
     }
     
     @Test
+    @Deprecated
     public void testAlterSegmentV2() throws Exception {
+        // TODO this test should remove after we disable segment v1 completely
         Database db = Catalog.getCurrentCatalog().getDb("default_cluster:test");
         Assert.assertNotNull(db);
         OlapTable tbl = (OlapTable) db.getTable("segmentv2");
diff --git a/fe/fe-core/src/test/java/org/apache/doris/common/PropertyAnalyzerTest.java b/fe/fe-core/src/test/java/org/apache/doris/common/PropertyAnalyzerTest.java
index ddbf6c1..9239a71 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/common/PropertyAnalyzerTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/common/PropertyAnalyzerTest.java
@@ -26,6 +26,7 @@ import org.apache.doris.catalog.ScalarType;
 import org.apache.doris.catalog.Type;
 import org.apache.doris.common.util.PropertyAnalyzer;
 import org.apache.doris.common.util.TimeUtils;
+import org.apache.doris.thrift.TStorageFormat;
 import org.apache.doris.thrift.TStorageMedium;
 
 import com.google.common.collect.Lists;
@@ -33,14 +34,19 @@ import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 
 import org.junit.Assert;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 import java.text.SimpleDateFormat;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 public class PropertyAnalyzerTest {
+    @Rule
+    public ExpectedException expectedEx = ExpectedException.none();
 
     @Test
     public void testBfColumns() throws AnalysisException {
@@ -144,4 +150,21 @@ public class PropertyAnalyzerTest {
         DateLiteral dateLiteral = new DateLiteral(tomorrowTimeStr, Type.DATETIME);
         Assert.assertEquals(dateLiteral.unixTimestamp(TimeUtils.getTimeZone()), dataProperty.getCooldownTimeMs());
     }
+
+    @Test
+    public void testStorageFormat() throws AnalysisException {
+        HashMap<String, String> propertiesV1 = Maps.newHashMap();
+        HashMap<String, String>  propertiesV2 = Maps.newHashMap();
+        HashMap<String, String>  propertiesDefault = Maps.newHashMap();
+        propertiesV1.put(PropertyAnalyzer.PROPERTIES_STORAGE_FORMAT, "v1");
+        propertiesV2.put(PropertyAnalyzer.PROPERTIES_STORAGE_FORMAT, "v2");
+        propertiesDefault.put(PropertyAnalyzer.PROPERTIES_STORAGE_FORMAT, "default");
+        Assert.assertEquals(TStorageFormat.V2, PropertyAnalyzer.analyzeStorageFormat(null));
+        Assert.assertEquals(TStorageFormat.V2, PropertyAnalyzer.analyzeStorageFormat(propertiesV2));
+        Assert.assertEquals(TStorageFormat.V2, PropertyAnalyzer.analyzeStorageFormat(propertiesDefault));
+        expectedEx.expect(AnalysisException.class);
+        expectedEx.expectMessage("Storage format V1 has been deprecated since version 0.14," +
+                " please use V2 instead");
+        PropertyAnalyzer.analyzeStorageFormat(propertiesV1);
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org