This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 5ab62ee80e3 branch-3.0: [fix](nereids) fix create view use null
literal #49881 (#51005)
5ab62ee80e3 is described below
commit 5ab62ee80e3b4df41c967cb8e3cbee02858f562b
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Sat May 24 11:04:46 2025 +0800
branch-3.0: [fix](nereids) fix create view use null literal #49881 (#51005)
Cherry-picked from #49881
Co-authored-by: feiniaofeiafei <[email protected]>
---
.../apache/doris/common/jni/vec/VectorColumn.java | 8 +--
.../trees/plans/commands/info/BaseViewInfo.java | 14 +++--
.../create_view_nereids_fix_null.out | Bin 0 -> 153 bytes
.../create_view_nereids_fix_null.groovy | 57 +++++++++++++++++++++
4 files changed, 72 insertions(+), 7 deletions(-)
diff --git
a/fe/be-java-extensions/java-common/src/main/java/org/apache/doris/common/jni/vec/VectorColumn.java
b/fe/be-java-extensions/java-common/src/main/java/org/apache/doris/common/jni/vec/VectorColumn.java
index b851afeebb5..04609ab1b1f 100644
---
a/fe/be-java-extensions/java-common/src/main/java/org/apache/doris/common/jni/vec/VectorColumn.java
+++
b/fe/be-java-extensions/java-common/src/main/java/org/apache/doris/common/jni/vec/VectorColumn.java
@@ -1180,7 +1180,7 @@ public class VectorColumn {
}
}
}
- childColumns[0].appendObjectColumn(nested, isNullable);
+ childColumns[0].appendObjectColumn(nested, true);
}
public ArrayList<Object> getArray(int rowId) {
@@ -1247,8 +1247,8 @@ public class VectorColumn {
}
}
}
- childColumns[0].appendObjectColumn(keys, isNullable);
- childColumns[1].appendObjectColumn(values, isNullable);
+ childColumns[0].appendObjectColumn(keys, true);
+ childColumns[1].appendObjectColumn(values, true);
}
public HashMap<Object, Object> getMap(int rowId) {
@@ -1313,7 +1313,7 @@ public class VectorColumn {
appendIndex++;
}
for (int j = 0; j < childColumns.length; ++j) {
- childColumns[j].appendObjectColumn(columnData[j], isNullable);
+ childColumns[j].appendObjectColumn(columnData[j], true);
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/BaseViewInfo.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/BaseViewInfo.java
index 8df0f83b0b6..ad653fbc182 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/BaseViewInfo.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/BaseViewInfo.java
@@ -62,6 +62,10 @@ import
org.apache.doris.nereids.trees.plans.logical.LogicalTopN;
import org.apache.doris.nereids.trees.plans.logical.LogicalView;
import org.apache.doris.nereids.trees.plans.logical.LogicalWindow;
import org.apache.doris.nereids.trees.plans.visitor.DefaultPlanVisitor;
+import org.apache.doris.nereids.types.DataType;
+import org.apache.doris.nereids.types.NullType;
+import org.apache.doris.nereids.types.TinyIntType;
+import org.apache.doris.nereids.util.TypeCoercionUtils;
import org.apache.doris.nereids.util.Utils;
import org.apache.doris.qe.ConnectContext;
@@ -161,8 +165,9 @@ public class BaseViewInfo {
protected void createFinalCols(List<Slot> outputs) throws
org.apache.doris.common.AnalysisException {
if (simpleColumnDefinitions.isEmpty()) {
for (Slot output : outputs) {
- Column column = new Column(output.getName(),
output.getDataType().toCatalogDataType(),
- output.nullable());
+ DataType dataType =
TypeCoercionUtils.replaceSpecifiedType(output.getDataType(), NullType.class,
+ TinyIntType.INSTANCE);
+ Column column = new Column(output.getName(),
dataType.toCatalogDataType(), output.nullable());
finalCols.add(column);
}
} else {
@@ -170,8 +175,11 @@ public class BaseViewInfo {
ErrorReport.reportAnalysisException(ErrorCode.ERR_VIEW_WRONG_LIST);
}
for (int i = 0; i < simpleColumnDefinitions.size(); ++i) {
+ Slot output = outputs.get(i);
+ DataType dataType =
TypeCoercionUtils.replaceSpecifiedType(output.getDataType(), NullType.class,
+ TinyIntType.INSTANCE);
Column column = new
Column(simpleColumnDefinitions.get(i).getName(),
- outputs.get(i).getDataType().toCatalogDataType(),
outputs.get(i).nullable());
+ dataType.toCatalogDataType(), output.nullable());
column.setComment(simpleColumnDefinitions.get(i).getComment());
finalCols.add(column);
}
diff --git
a/regression-test/data/ddl_p0/create_view_nereids/create_view_nereids_fix_null.out
b/regression-test/data/ddl_p0/create_view_nereids/create_view_nereids_fix_null.out
new file mode 100644
index 00000000000..62698117493
Binary files /dev/null and
b/regression-test/data/ddl_p0/create_view_nereids/create_view_nereids_fix_null.out
differ
diff --git
a/regression-test/suites/ddl_p0/create_view_nereids/create_view_nereids_fix_null.groovy
b/regression-test/suites/ddl_p0/create_view_nereids/create_view_nereids_fix_null.groovy
new file mode 100644
index 00000000000..4ea07083be4
--- /dev/null
+++
b/regression-test/suites/ddl_p0/create_view_nereids/create_view_nereids_fix_null.groovy
@@ -0,0 +1,57 @@
+// 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.
+
+suite("create_view_nereids_fix_null") {
+ sql "drop view if exists test_null"
+ sql "CREATE VIEW test_null COMMENT '测试null类型' AS SELECT NULL AS `col1`; "
+ def res = sql "desc test_null"
+ mustContain(res[0][1], "tinyint")
+
+ sql "drop view if exists test_null_array"
+ sql "CREATE VIEW test_null_array COMMENT '测试null类型' AS SELECT [NULL,
NULL] AS `col1`; "
+ def res2 = sql "desc test_null_array"
+ mustContain(res2[0][1], "array<tinyint>")
+ mustContain(res2[0][2], "No")
+
+ String s3_endpoint = getS3Endpoint()
+ logger.info("s3_endpoint: " + s3_endpoint)
+ String bucket = getS3BucketName()
+ logger.info("bucket: " + bucket)
+ String driver_url =
"https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-java-8.0.25.jar"
+ String dbname = context.config.getDbNameByFile(context.file)
+ String jdbcUrl = context.config.jdbcUrl
+ String jdbcUser = context.config.jdbcUser
+ logger.info("jdbcUser: " + jdbcUser)
+ String jdbcPassword = context.config.jdbcPassword
+ logger.info("jdbcPassword: " + jdbcPassword)
+ sql "drop catalog if exists create_view_nereids_fix_null_catalog"
+ sql """
+ CREATE CATALOG create_view_nereids_fix_null_catalog PROPERTIES (
+ "type"="jdbc",
+ "user"="${jdbcUser}",
+ "password"="${jdbcPassword}",
+ "jdbc_url"="${jdbcUrl}",
+ "driver_url"="${driver_url}",
+ "driver_class"="com.mysql.cj.jdbc.Driver"
+ );
+ """
+ sql "switch create_view_nereids_fix_null_catalog"
+ sql "use ${dbname}"
+ qt_test_null "select * from test_null"
+ qt_test_null_array "select * from test_null_array"
+ sql "drop catalog create_view_nereids_fix_null_catalog;"
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]