[Enhancement](array-type) enable_array_type flag update (#11785)
Co-authored-by: cambyzju <zhuxiaoli01@baidu.com>
This commit is contained in:
@ -17,7 +17,7 @@
|
||||
|
||||
package org.apache.doris.catalog;
|
||||
|
||||
import org.apache.doris.qe.ConnectContext;
|
||||
import org.apache.doris.common.Config;
|
||||
import org.apache.doris.thrift.TColumnType;
|
||||
import org.apache.doris.thrift.TTypeDesc;
|
||||
import org.apache.doris.thrift.TTypeNode;
|
||||
@ -155,7 +155,7 @@ public class ArrayType extends Type {
|
||||
|
||||
@Override
|
||||
public boolean isSupported() {
|
||||
if (!ConnectContext.get().getSessionVariable().isEnableArrayType()) {
|
||||
if (!Config.enable_array_type) {
|
||||
return false;
|
||||
}
|
||||
return !itemType.isNull();
|
||||
|
||||
@ -1732,4 +1732,10 @@ public class Config extends ConfigBase {
|
||||
*/
|
||||
@ConfField
|
||||
public static String s3_compatible_object_storages = "s3,oss,cos,bos";
|
||||
|
||||
/**
|
||||
* Support complex data type ARRAY.
|
||||
*/
|
||||
@ConfField(mutable = true, masterOnly = true)
|
||||
public static boolean enable_array_type = false;
|
||||
}
|
||||
|
||||
@ -195,8 +195,6 @@ public class SessionVariable implements Serializable, Writable {
|
||||
public static final String TRIM_TAILING_SPACES_FOR_EXTERNAL_TABLE_QUERY
|
||||
= "trim_tailing_spaces_for_external_table_query";
|
||||
|
||||
static final String ENABLE_ARRAY_TYPE = "enable_array_type";
|
||||
|
||||
public static final String ENABLE_NEREIDS_PLANNER = "enable_nereids_planner";
|
||||
|
||||
public static final String ENABLE_NEREIDS_REORDER_TO_ELIMINATE_CROSS_JOIN =
|
||||
@ -497,9 +495,6 @@ public class SessionVariable implements Serializable, Writable {
|
||||
@VariableMgr.VarAttr(name = ENABLE_PROJECTION)
|
||||
private boolean enableProjection = true;
|
||||
|
||||
@VariableMgr.VarAttr(name = ENABLE_ARRAY_TYPE)
|
||||
private boolean enableArrayType = false;
|
||||
|
||||
/**
|
||||
* as the new optimizer is not mature yet, use this var
|
||||
* to control whether to use new optimizer, remove it when
|
||||
@ -1036,14 +1031,6 @@ public class SessionVariable implements Serializable, Writable {
|
||||
this.disableJoinReorder = disableJoinReorder;
|
||||
}
|
||||
|
||||
public boolean isEnableArrayType() {
|
||||
return enableArrayType;
|
||||
}
|
||||
|
||||
public void setEnableArrayType(boolean enableArrayType) {
|
||||
this.enableArrayType = enableArrayType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Nereids only support vectorized engine.
|
||||
*
|
||||
|
||||
@ -25,6 +25,7 @@ import org.apache.doris.catalog.PrimitiveType;
|
||||
import org.apache.doris.catalog.ScalarType;
|
||||
import org.apache.doris.catalog.Type;
|
||||
import org.apache.doris.common.AnalysisException;
|
||||
import org.apache.doris.common.Config;
|
||||
import org.apache.doris.qe.ConnectContext;
|
||||
|
||||
import mockit.Mock;
|
||||
@ -46,6 +47,7 @@ public class ColumnDefTest {
|
||||
stringCol = new TypeDef(ScalarType.createChar(10));
|
||||
floatCol = new TypeDef(ScalarType.createType(PrimitiveType.FLOAT));
|
||||
booleanCol = new TypeDef(ScalarType.createType(PrimitiveType.BOOLEAN));
|
||||
Config.enable_array_type = true;
|
||||
|
||||
ctx = new ConnectContext(null);
|
||||
new MockUp<ConnectContext>() {
|
||||
@ -133,7 +135,6 @@ public class ColumnDefTest {
|
||||
|
||||
@Test
|
||||
public void testArray() throws AnalysisException {
|
||||
ctx.getSessionVariable().setEnableArrayType(true);
|
||||
TypeDef typeDef = new TypeDef(new ArrayType(Type.INT));
|
||||
ColumnDef columnDef = new ColumnDef("array", typeDef, false, null, true, DefaultValue.NOT_SET, "");
|
||||
Column column = columnDef.toColumn();
|
||||
|
||||
@ -21,6 +21,7 @@ import org.apache.doris.catalog.ArrayType;
|
||||
import org.apache.doris.catalog.Env;
|
||||
import org.apache.doris.catalog.PrimitiveType;
|
||||
import org.apache.doris.common.AnalysisException;
|
||||
import org.apache.doris.common.Config;
|
||||
import org.apache.doris.common.ExceptionChecker;
|
||||
import org.apache.doris.common.util.SqlParserUtils;
|
||||
import org.apache.doris.qe.ConnectContext;
|
||||
@ -43,7 +44,7 @@ public class InsertArrayStmtTest {
|
||||
public static void setUp() throws Exception {
|
||||
UtFrameUtils.createDorisCluster(RUNNING_DIR);
|
||||
connectContext = UtFrameUtils.createDefaultCtx();
|
||||
connectContext.getSessionVariable().setEnableArrayType(true);
|
||||
Config.enable_array_type = true;
|
||||
createDatabase("create database test;");
|
||||
}
|
||||
|
||||
|
||||
@ -45,6 +45,7 @@ public class CreateTableTest {
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
Config.disable_storage_medium_check = true;
|
||||
Config.enable_array_type = true;
|
||||
UtFrameUtils.createDorisCluster(runningDir);
|
||||
|
||||
// create connect context
|
||||
@ -560,7 +561,6 @@ public class CreateTableTest {
|
||||
|
||||
@Test
|
||||
public void testCreateTableWithArrayType() throws Exception {
|
||||
ConnectContext.get().getSessionVariable().setEnableArrayType(true);
|
||||
ExceptionChecker.expectThrowsNoException(() -> {
|
||||
createTable("create table test.table1(k1 INT, k2 Array<int>) duplicate key (k1) "
|
||||
+ "distributed by hash(k1) buckets 1 properties('replication_num' = '1');");
|
||||
|
||||
Reference in New Issue
Block a user