diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/source/MaxComputeScanNode.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/source/MaxComputeScanNode.java index 24c681c8959912..bf09288be98508 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/source/MaxComputeScanNode.java +++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/maxcompute/source/MaxComputeScanNode.java @@ -357,8 +357,8 @@ private Predicate convertExprToOdpsPredicate(Expr expr) throws AnalysisException InPredicate inPredicate = (InPredicate) expr; com.aliyun.odps.table.optimizer.predicate.InPredicate.Operator odpsOp = inPredicate.isNotIn() - ? com.aliyun.odps.table.optimizer.predicate.InPredicate.Operator.IN - : com.aliyun.odps.table.optimizer.predicate.InPredicate.Operator.NOT_IN; + ? com.aliyun.odps.table.optimizer.predicate.InPredicate.Operator.NOT_IN + : com.aliyun.odps.table.optimizer.predicate.InPredicate.Operator.IN; String columnName = convertSlotRefToColumnName(expr.getChild(0)); if (!table.getColumnNameToOdpsColumn().containsKey(columnName)) { diff --git a/regression-test/data/external_table_p2/maxcompute/test_max_compute_in_predicate_pushdown.out b/regression-test/data/external_table_p2/maxcompute/test_max_compute_in_predicate_pushdown.out new file mode 100644 index 00000000000000..3adc7524af7700 --- /dev/null +++ b/regression-test/data/external_table_p2/maxcompute/test_max_compute_in_predicate_pushdown.out @@ -0,0 +1,25 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !in_single -- +1 str +3 str + +-- !in_multi -- +1 str +2 string_value +3 str +4 string_value + +-- !not_in_single -- +2 string_value +4 string_value + +-- !not_in_multi -- + +-- !in_non_pushdown -- +1 str +3 str + +-- !not_in_non_pushdown -- +2 string_value +4 string_value + diff --git a/regression-test/suites/external_table_p2/maxcompute/test_max_compute_in_predicate_pushdown.groovy b/regression-test/suites/external_table_p2/maxcompute/test_max_compute_in_predicate_pushdown.groovy new file mode 100644 index 00000000000000..3e7cc353ac6903 --- /dev/null +++ b/regression-test/suites/external_table_p2/maxcompute/test_max_compute_in_predicate_pushdown.groovy @@ -0,0 +1,102 @@ +// 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("test_max_compute_in_predicate_pushdown", "p2,external,maxcompute,external_remote,external_remote_maxcompute") { + String enabled = context.config.otherConfigs.get("enableMaxComputeTest") + if (enabled != null && enabled.equalsIgnoreCase("true")) { + String ak = context.config.otherConfigs.get("ak") + String sk = context.config.otherConfigs.get("sk") + String mcCatalogName = "test_max_compute_in_predicate_pushdown" + String defaultProject = "mc_datalake" + String tableName = "mc_all_types" + + sql """drop catalog if exists ${mcCatalogName} """ + sql """ + create catalog if not exists ${mcCatalogName} properties ( + "type" = "max_compute", + "mc.default.project" = "${defaultProject}", + "mc.access_key" = "${ak}", + "mc.secret_key" = "${sk}", + "mc.endpoint" = "http://service.cn-beijing-vpc.maxcompute.aliyun-inc.com/api", + "mc.quota" = "pay-as-you-go" + ); + """ + + sql """switch ${mcCatalogName};""" + sql """use ${defaultProject};""" + + def pushdownInSingle = sql """ + select id, string_col from ${tableName} + where string_col in ("str") + order by id + """ + def localInSingle = sql """ + select id, string_col from ${tableName} + where concat(string_col, "") in ("str") + order by id + """ + assertEquals(localInSingle, pushdownInSingle) + + def pushdownNotInSingle = sql """ + select id, string_col from ${tableName} + where string_col not in ("str") + order by id + """ + def localNotInSingle = sql """ + select id, string_col from ${tableName} + where concat(string_col, "") not in ("str") + order by id + """ + assertEquals(localNotInSingle, pushdownNotInSingle) + + order_qt_in_single """ + select id, string_col from ${tableName} + where string_col in ("str") + order by id + """ + + order_qt_in_multi """ + select id, string_col from ${tableName} + where string_col in ("str", "string_value") + order by id + """ + + order_qt_not_in_single """ + select id, string_col from ${tableName} + where string_col not in ("str") + order by id + """ + + order_qt_not_in_multi """ + select id, string_col from ${tableName} + where string_col not in ("str", "string_value") + order by id + """ + + order_qt_in_non_pushdown """ + select id, string_col from ${tableName} + where concat(string_col, "") in ("str") + order by id + """ + + order_qt_not_in_non_pushdown """ + select id, string_col from ${tableName} + where concat(string_col, "") not in ("str") + order by id + """ + } +}