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

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


The following commit(s) were added to refs/heads/master by this push:
     new 9b5352b93ea [improvement](external) Hand ARRAY literals to connectors 
as element lists (#70369)
9b5352b93ea is described below

commit 9b5352b93eacd3a122e8fbdfd6e3e92105ef6f44
Author: Mingyu Chen (Rayner) <[email protected]>
AuthorDate: Tue Nov 17 13:56:12 2026 +0800

    [improvement](external) Hand ARRAY literals to connectors as element lists 
(#70369)
    
    ### Background
    
    A catalog connector learns which filters it may push down from an
    engine-neutral expression tree (`ConnectorExpression`) that fe-core's
    `ExprToConnectorExpressionConverter` builds from the planner's
    conjuncts. A literal in that tree carries a plain Java value whose shape
    the SPI documents per Doris type (Rule 4 in
    `connector/spi/pushdown/package-info.java`): `Long` for integers,
    `LocalDate` for dates, and so on. Types outside that table, ARRAY among
    them, arrive as the literal's display text.
    
    ### What problem does this PR solve?
    
    Issue Number: None
    Related PR: #68687 (the Lance array-membership pushdown on branch-4.2,
    whose master port needs the elements)
    PR Type: Enhancement
    
    Problem Summary:
    
    An ARRAY literal reaches a connector as text such as `[red, a, b]`, with
    unquoted elements, so `['a, b']` and `['a', 'b']` cannot be told apart.
    The Lance connector needs the elements to push down `arrays_overlap`,
    which the planner makes from three or more ORed `array_contains`. This
    PR makes the value an unmodifiable `List` of element values, each in the
    shape the SPI gives its element type. An audit of the connectors that
    read literal values found two that already mishandled the text and would
    mishandle the list: JDBC sent the text to the source, which PostgreSQL
    and ClickHouse reject and a remote Doris reads back as other elements,
    and would write the list unquoted; Elasticsearch pushed array
    comparisons as a term query on the text and stopped evaluating them.
    Both now leave such predicates to Doris. Since the converter drops
    CASTs, a conjunct that casts into or out of ARRAY, MAP or STRUCT, such
    as `p = CAST([TRUE] AS STRING)`, now stays in Doris, and Hive and Hudi
    do not prune by it.
    
    ### Details
    
    - **Change map:** 128 lines of production code, 554 of tests and 100 of
    generated `.out`, in three commits. The code is the converter's ARRAY
    branch (19 lines) and the JDBC and ES checks (10) in the first commit,
    then the third commit's guards for casts the converter drops: one in
    `PluginDrivenScanNode.buildRemainingFilter` (28) and one each in Hive
    and Hudi partition pruning (42); the SPI documentation of both (29) is
    split between them. The tests are unit tests of the converter, both
    query builders, the scan node and the two pruners (326), and the second
    commit's two regression suites (228).
    - **Before and after:** For `['red', 'a, b', NULL]`,
    `ConnectorLiteral#getValue()` was the String `[red, a, b, NULL]` and is
    now the list `["red", "a, b", null]`; nested arrays are nested lists,
    and a NULL array is still a NULL literal. An element has the value it
    would have as a literal of its own (a LARGEINT element is still a
    decimal String). JDBC: `tags = ['a', 'b']`, or on MySQL
    `arrays_overlap(tags, ['a', 'b'])`, is no longer sent to the source,
    where it went as the string `'[a, b]'`. Elasticsearch (docvalue mode):
    `tags = ['red', 'blue']` is no longer pushed as `{"term":{"tags":"[red,
    blue]"}}`. A conjunct that casts into or out of ARRAY, MAP or STRUCT,
    such as `p = CAST([TRUE] AS STRING)` or `CAST(arr AS STRING) = '[1]'`,
    reached connectors that accept casts as its bare operand and now stays
    in Doris; a cast between two ARRAY types still reaches them. Hive and
    Hudi read the operand of `p = CAST([TRUE] AS STRING)` as the partition
    value `[true]` (master read `[1]`, right for this element type only);
    they now take no partition value from a complex-typed literal, nor prune
    by an IN holding anything but scalar literals.
    - **Configs and defaults:** None.
    - **Impact on existing users:** JDBC catalogs filter such rows in Doris
    instead of the source, and the query no longer pushes LIMIT. Queries
    that failed now run (PostgreSQL: `malformed array literal`; ClickHouse
    string arrays: `Cannot parse quoted string`; a remote Doris: no
    signature for `arrays_overlap(ARRAY<TEXT>, VARCHAR)`), and a remote
    Doris, which parsed the text into other elements, no longer loses rows
    whose elements contain `, ` or NULL. Elasticsearch dropped a pushed
    comparison from what Doris evaluates, while a term query matches any one
    value of a multi-valued field: on ES 7.17.5 and 8.3.3 a docvalue scan
    returned no row for `=`, every row for `!=`, and failed the query for a
    long array. ADBC, Iceberg, Paimon, MaxCompute and Trino already refuse
    ARRAY literals. Hive and Hudi partition pruning sees one only behind a
    CAST the converter drops, and now prunes nothing by it, and any filter
    with a cast into or out of a complex type, with its LIMIT, stays in
    Doris. No SPI type or method changes, so the connector plugin API
    version stays.
    
    ### Testing
    
    All run locally, the first commit's tests and the regression suites
    before the rebase onto `ee73acc6131`, the rest on the head:
    
    - New `ExprToConnectorExpressionConverterTest` (fe-core): elements with
    commas and quotes, every scalar shape, NULL elements, nested and empty
    arrays, an unmodifiable list, a NULL array. 4 tests pass; with the new
    branch removed (master's behavior) all 4 fail.
    - `JdbcQueryBuilderTest#testArrayLiteralsRemainLocalWithoutLimit`
    (MySQL, PostgreSQL, ClickHouse, Trino): no WHERE or LIMIT for a
    comparison, NOT or `arrays_overlap` with an ARRAY literal; an AND keeps
    its other conjunct. Without the new check the builder emits ``WHERE
    (`tags` = [a, b, x') OR ('1'='1]) LIMIT 1``.
    - `EsQueryDslBuilderTest#arrayLiteralComparisonsRemainLocal`: `=`, `!=`,
    `<` on either side stay in Doris; in an AND the other conjunct is still
    pushed.
    - `PluginDrivenScanNodeCastPredicateTest` (fe-core, planned queries,
    casts accepted): `code = CAST([true] AS STRING)`, an IN and a LIKE with
    such a cast, `CAST(arr AS STRING) = '[1]'`, `arr = CAST('[1]' AS
    ARRAY<INT>)`, and MAP and STRUCT columns cast to STRING stay in Doris,
    and `CAST(arr AS ARRAY<BIGINT>) = [1, 2]` is still pushed. Each case
    also shows that FE keeps the CAST.
    - `HudiPartitionPruningTest` and
    `HiveConnectorMetadataPartitionPruningTest`: an EQ or IN with an ARRAY,
    MAP or STRUCT literal, or an IN holding a function call, prunes nothing,
    and Hive asks HMS for no filter; an IN with a NULL item still prunes.
    - Mutations, each against its test class beside an unmutated control,
    all fail a new test: six of the first commit (text instead of the list,
    a modifiable list, elements as text, NULL elements dropped, each
    connector check removed) and 15 of the third (its guard off; its ARRAY,
    MAP or STRUCT clause off; a cast between two ARRAY types treated as a
    change of kind; in Hive and in Hudi the EQ guard, the IN guard and each
    type name off), each of which fails only the cases it targets.
    - Existing suites pass on the head: fe-connector-hive (580),
    fe-connector-hudi (272), fe-connector-spi (152, with
    `ConnectorPluginSurfaceTest`), fe-connector-es (164), fe-connector-jdbc
    (275), and in fe-core the converters that route through this one plus
    `PluginDrivenScanNode*Test` (291).
    - New `test_jdbc_array_literal_predicate` (p0, external) runs such
    filters against a remote Doris (the cluster itself), PostgreSQL and
    ClickHouse: `, ` and NULL elements, INT and nested arrays,
    `arrays_overlap` and the ORed `array_contains` the planner rewrites into
    it, AND, OR and LIMIT. Each block returns the source's rows and the
    remote query carries no array filter or LIMIT. With master's converter
    each source's part fails; without the JDBC check the remote Doris
    rejects ``WHERE (`tags` = [a, b])``.
    - New `test_es_array_literal_predicate` (p2, like the other ES suites)
    does the same on ES 7 and 8 in a docvalue scan. With master's converter
    or without the ES check, `c_keyword = ['a', 'b', 'c']` returns no row
    instead of five.
    - Both suites ran on a local cluster with this branch's FE, PostgreSQL
    14, ClickHouse 23.8 and ES 7.17.5 / 8.3.3 in single containers loaded
    with the tables the suites read.
    - End to end, on a local cluster whose FE also carries the Lance
    connector PR that builds on this one:
    `test_lance_array_predicate_pushdown` pushes `arrays_overlap(labels,
    [...])` into Lance, up to the 64-needle index budget, and its BE profile
    shows the scalar index segments searched.
    
    ### Notes for Reviewers
    
    - `NereidsToConnectorExpressionConverter` (DELETE / UPDATE / MERGE) and
    `UnboundExpressionToConnectorPredicateConverter` (`EXECUTE ... WHERE`)
    convert literals through `ExprToConnectorExpressionConverter`, so all
    three paths get the list.
    - `convertLiteral` and `convertDateLiteral` now declare
    `ConnectorLiteral`, which they always returned, so the element loop
    needs no cast.
    - The cast guard sits once in `buildRemainingFilter`, beside the
    TIMESTAMPTZ one, because the remaining filter has many readers;
    `applyFilter` receives every conjunct by design, so its readers, Hive
    and Hudi (Trino's returns no result), check the literal. Wrapping such a
    cast in the converter's `fallback()` would not be safe: JDBC writes an
    argument-less call into the remote SQL as text.
    - MAP, STRUCT and the cast from a scalar into an ARRAY are covered with
    ARRAY because the same holds for them: the operand of a cast between
    kinds is never the value the cast yields.
---
 .../doris/connector/es/EsQueryDslBuilder.java      |   6 +
 .../doris/connector/es/EsQueryDslBuilderTest.java  |  22 +++
 .../connector/hive/HiveConnectorMetadata.java      |  21 ++-
 .../HiveConnectorMetadataPartitionPruningTest.java |  54 +++++++
 .../connector/hudi/HudiConnectorMetadata.java      |  21 ++-
 .../connector/hudi/HudiPartitionPruningTest.java   |  58 ++++++++
 .../doris/connector/jdbc/JdbcQueryBuilder.java     |   4 +
 .../doris/connector/jdbc/JdbcQueryBuilderTest.java |  27 ++++
 .../doris/connector/spi/ConnectorPushdownOps.java  |   7 +-
 .../connector/spi/pushdown/ConnectorLiteral.java   |   5 +-
 .../doris/connector/spi/pushdown/package-info.java |  17 ++-
 .../ExprToConnectorExpressionConverter.java        |  19 ++-
 .../datasource/scan/PluginDrivenScanNode.java      |  28 +++-
 .../ExprToConnectorExpressionConverterTest.java    | 125 ++++++++++++++++
 .../PluginDrivenScanNodeCastPredicateTest.java     |  40 +++++-
 .../jdbc/test_jdbc_array_literal_predicate.out     |  57 ++++++++
 .../es/test_es_array_literal_predicate.out         |  43 ++++++
 .../jdbc/test_jdbc_array_literal_predicate.groovy  | 157 +++++++++++++++++++++
 .../es/test_es_array_literal_predicate.groovy      |  71 ++++++++++
 19 files changed, 764 insertions(+), 18 deletions(-)

diff --git 
a/fe/fe-connector/fe-connector-es/src/main/java/org/apache/doris/connector/es/EsQueryDslBuilder.java
 
b/fe/fe-connector/fe-connector-es/src/main/java/org/apache/doris/connector/es/EsQueryDslBuilder.java
index c82bca90d16..57717e66705 100644
--- 
a/fe/fe-connector/fe-connector-es/src/main/java/org/apache/doris/connector/es/EsQueryDslBuilder.java
+++ 
b/fe/fe-connector/fe-connector-es/src/main/java/org/apache/doris/connector/es/EsQueryDslBuilder.java
@@ -467,6 +467,12 @@ public final class EsQueryDslBuilder {
             return null;
         }
         ConnectorLiteral literal = (ConnectorLiteral) valueExpr;
+        // An ARRAY literal compares whole arrays, but a term or range query 
matches any one value of a
+        // multi-valued field, so Doris evaluates the comparison itself.
+        if (literal.getValue() instanceof List) {
+            notPushDownList.add(comparison);
+            return null;
+        }
 
         if (isFlip) {
             op = flipOperator(op);
diff --git 
a/fe/fe-connector/fe-connector-es/src/test/java/org/apache/doris/connector/es/EsQueryDslBuilderTest.java
 
b/fe/fe-connector/fe-connector-es/src/test/java/org/apache/doris/connector/es/EsQueryDslBuilderTest.java
index d8135555521..c2fadf1da21 100644
--- 
a/fe/fe-connector/fe-connector-es/src/test/java/org/apache/doris/connector/es/EsQueryDslBuilderTest.java
+++ 
b/fe/fe-connector/fe-connector-es/src/test/java/org/apache/doris/connector/es/EsQueryDslBuilderTest.java
@@ -143,6 +143,28 @@ public class EsQueryDslBuilderTest {
                 buildWithTracking(new ConnectorNot(new 
ConnectorOr(Arrays.asList(eq, ne)))).getQueryDsl());
     }
 
+    @Test
+    void arrayLiteralComparisonsRemainLocal() {
+        ConnectorType stringArray = 
ConnectorType.arrayOf(ConnectorType.of("VARCHAR"));
+        ConnectorColumnRef tags = new ConnectorColumnRef("tags", stringArray);
+        ConnectorLiteral array = new ConnectorLiteral(stringArray, 
Arrays.asList("red", "blue"));
+        for (ConnectorComparison.Operator op : 
Arrays.asList(ConnectorComparison.Operator.EQ,
+                ConnectorComparison.Operator.NE, 
ConnectorComparison.Operator.LT)) {
+            for (ConnectorExpression comparison : Arrays.asList(new 
ConnectorComparison(op, tags, array),
+                    new ConnectorComparison(op, array, tags))) {
+                EsQueryDslResult result = 
EsQueryDslBuilder.buildQueryDslWithResult(comparison,
+                        Collections.emptyMap(), Collections.emptyMap(), true, 
Collections.emptyList());
+                Assertions.assertEquals(Collections.singletonList(0), 
result.getNotPushedIndices(), comparison.toString());
+                Assertions.assertEquals(EsQueryDslBuilder.matchAllQuery(), 
result.getQueryDsl());
+            }
+        }
+        EsQueryDslResult partial = 
EsQueryDslBuilder.buildQueryDslWithResult(new ConnectorAnd(Arrays.asList(
+                keywordEquals("one"), new 
ConnectorComparison(ConnectorComparison.Operator.EQ, tags, array))),
+                Collections.emptyMap(), Collections.singletonMap("name", 
"keyword"), true, Collections.emptyList());
+        Assertions.assertEquals(Collections.singletonList(1), 
partial.getNotPushedIndices());
+        Assertions.assertEquals("{\"term\":{\"name\":\"one\"}}", 
partial.getQueryDsl());
+    }
+
     @Test
     void notEqualExcludesMissingValuesForEveryNonNullLiteral() {
         for (ConnectorLiteral literal : 
Arrays.asList(ConnectorLiteral.ofLong(1),
diff --git 
a/fe/fe-connector/fe-connector-hive/src/main/java/org/apache/doris/connector/hive/HiveConnectorMetadata.java
 
b/fe/fe-connector/fe-connector-hive/src/main/java/org/apache/doris/connector/hive/HiveConnectorMetadata.java
index dd49e8ce7b1..1f150a0b051 100644
--- 
a/fe/fe-connector/fe-connector-hive/src/main/java/org/apache/doris/connector/hive/HiveConnectorMetadata.java
+++ 
b/fe/fe-connector/fe-connector-hive/src/main/java/org/apache/doris/connector/hive/HiveConnectorMetadata.java
@@ -2554,7 +2554,7 @@ public class HiveConnectorMetadata implements 
ConnectorMetadata {
             }
         } else if (expr instanceof ConnectorComparison) {
             ConnectorComparison cmp = (ConnectorComparison) expr;
-            if (cmp.getOperator() == ConnectorComparison.Operator.EQ) {
+            if (cmp.getOperator() == ConnectorComparison.Operator.EQ && 
isScalarLiteral(cmp.getRight())) {
                 String colName = extractColumnName(cmp.getLeft());
                 String value = extractLiteralValue(cmp.getRight());
                 if (colName != null && value != null && 
partKeySet.contains(colName)) {
@@ -2563,12 +2563,15 @@ public class HiveConnectorMetadata implements 
ConnectorMetadata {
             }
         } else if (expr instanceof ConnectorIn) {
             ConnectorIn inExpr = (ConnectorIn) expr;
-            if (!inExpr.isNegated()) {
+            // Skipping an item that is not a partition value would narrow the 
list and drop the partitions
+            // that item matches, so an IN prunes only when every item is a 
scalar literal.
+            if (!inExpr.isNegated() && 
inExpr.getInList().stream().allMatch(HiveConnectorMetadata::isScalarLiteral)) {
                 String colName = extractColumnName(inExpr.getValue());
                 if (colName != null && partKeySet.contains(colName)) {
                     List<String> values = new ArrayList<>();
                     for (ConnectorExpression item : inExpr.getInList()) {
                         String val = extractLiteralValue(item);
+                        // A NULL item matches no partition.
                         if (val != null) {
                             values.add(val);
                         }
@@ -2588,6 +2591,20 @@ public class HiveConnectorMetadata implements 
ConnectorMetadata {
         return null;
     }
 
+    /**
+     * Whether {@code expr} is a literal that can stand for a partition value. 
A literal of type ARRAY, MAP or
+     * STRUCT arrives only as the operand of a CAST the engine stripped, as in 
{@code p = CAST([true] AS STRING)},
+     * and its value is not the text that cast yields (an ARRAY arrives as an 
element list), so it never prunes.
+     */
+    private static boolean isScalarLiteral(ConnectorExpression expr) {
+        if (!(expr instanceof ConnectorLiteral)) {
+            return false;
+        }
+        String typeName = ((ConnectorLiteral) expr).getType().getTypeName();
+        return !"ARRAY".equalsIgnoreCase(typeName) && 
!"MAP".equalsIgnoreCase(typeName)
+                && !"STRUCT".equalsIgnoreCase(typeName);
+    }
+
     private String extractLiteralValue(ConnectorExpression expr) {
         if (!(expr instanceof ConnectorLiteral)) {
             return null;
diff --git 
a/fe/fe-connector/fe-connector-hive/src/test/java/org/apache/doris/connector/hive/HiveConnectorMetadataPartitionPruningTest.java
 
b/fe/fe-connector/fe-connector-hive/src/test/java/org/apache/doris/connector/hive/HiveConnectorMetadataPartitionPruningTest.java
index 3693a697e9c..22469d25a80 100644
--- 
a/fe/fe-connector/fe-connector-hive/src/test/java/org/apache/doris/connector/hive/HiveConnectorMetadataPartitionPruningTest.java
+++ 
b/fe/fe-connector/fe-connector-hive/src/test/java/org/apache/doris/connector/hive/HiveConnectorMetadataPartitionPruningTest.java
@@ -30,6 +30,7 @@ import 
org.apache.doris.connector.spi.pushdown.ConnectorColumnRef;
 import org.apache.doris.connector.spi.pushdown.ConnectorComparison;
 import org.apache.doris.connector.spi.pushdown.ConnectorExpression;
 import org.apache.doris.connector.spi.pushdown.ConnectorFilterConstraint;
+import org.apache.doris.connector.spi.pushdown.ConnectorFunctionCall;
 import org.apache.doris.connector.spi.pushdown.ConnectorIn;
 import org.apache.doris.connector.spi.pushdown.ConnectorLiteral;
 import org.apache.doris.connector.spi.pushdown.FilterApplicationResult;
@@ -917,6 +918,59 @@ public class HiveConnectorMetadataPartitionPruningTest {
         }
     }
 
+    @Test
+    public void testComplexLiteralIsNeverAPartitionValue() {
+        // p = CAST([TRUE] AS STRING): the engine strips the CAST, so the 
literal arrives as the element list [true]
+        // while BE renders the cast as "[1]"; a MAP or STRUCT literal arrives 
as its display text. Read as a
+        // partition value, either would ask HMS for p = '[true]' and drop the 
p=[1] partition, and in an IN,
+        // skipping just that item would narrow the list to 'x'.
+        List<String> parts = Arrays.asList("p=%5B1%5D", "p=x");
+        for (ConnectorLiteral literal : complexLiterals()) {
+            HmsFilterClient client = new HmsFilterClient(parts, 
Collections.emptyList());
+            HiveConnectorMetadata metadata = new HiveConnectorMetadata(
+                    client, HiveTestProperties.minimal(), new 
FakeConnectorContext());
+            HiveTableHandle handle = typedHandle("p", "STRING");
+            for (ConnectorExpression expr : Arrays.asList(
+                    new ConnectorComparison(ConnectorComparison.Operator.EQ, 
colRef("p"), literal),
+                    new ConnectorIn(colRef("p"), Arrays.asList(literal, 
lit("x")), false))) {
+                Assertions.assertFalse(applyFilter(metadata, handle, 
expr).isPresent(), expr.toString());
+                Assertions.assertEquals(parts,
+                        partitionNames(metadata.listPartitions(null, handle, 
Optional.of(expr))), expr.toString());
+            }
+            Assertions.assertNull(client.filter, literal.toString());
+        }
+    }
+
+    @Test
+    public void testInListWithAnItemThatIsNotALiteralDoesNotPrune() {
+        // p IN (f(), 'x') with a call the planner did not fold: skipping the 
call would keep only p=x and lose the
+        // rows whose p equals what f() returns. A NULL item matches no 
partition, so the IN still prunes without it.
+        HmsFilterClient client = new HmsFilterClient(Arrays.asList("p=a", 
"p=x"), Collections.singletonList("p=x"));
+        HiveConnectorMetadata metadata = new HiveConnectorMetadata(
+                client, HiveTestProperties.minimal(), new 
FakeConnectorContext());
+        HiveTableHandle handle = typedHandle("p", "STRING");
+        ConnectorExpression withCall = new ConnectorIn(colRef("p"), 
Arrays.asList(
+                new ConnectorFunctionCall("f", ConnectorType.of("STRING"), 
Collections.emptyList()), lit("x")), false);
+        ConnectorExpression withNull = new ConnectorIn(colRef("p"),
+                
Arrays.asList(ConnectorLiteral.ofNull(ConnectorType.of("STRING")), lit("x")), 
false);
+
+        Assertions.assertFalse(applyFilter(metadata, handle, 
withCall).isPresent());
+        Assertions.assertNull(client.filter);
+        Assertions.assertEquals(Collections.singletonList("p=x"),
+                prunedLocations(applyFilter(metadata, handle, withNull)));
+    }
+
+    /** An ARRAY, a MAP and a STRUCT literal, each with the value the engine's 
converter gives that type. */
+    private static List<ConnectorLiteral> complexLiterals() {
+        return Arrays.asList(
+                new 
ConnectorLiteral(ConnectorType.arrayOf(ConnectorType.of("BOOLEAN")),
+                        Collections.singletonList(true)),
+                new 
ConnectorLiteral(ConnectorType.mapOf(ConnectorType.of("STRING"), 
ConnectorType.of("INT")),
+                        "{\"k\":1}"),
+                new 
ConnectorLiteral(ConnectorType.structOf(Collections.singletonList("f"),
+                        Collections.singletonList(ConnectorType.of("INT"))), 
"{\"f\":1}"));
+    }
+
     private List<String> partitionNames(List<ConnectorPartitionInfo> 
partitions) {
         List<String> names = new ArrayList<>();
         for (ConnectorPartitionInfo partition : partitions) {
diff --git 
a/fe/fe-connector/fe-connector-hudi/src/main/java/org/apache/doris/connector/hudi/HudiConnectorMetadata.java
 
b/fe/fe-connector/fe-connector-hudi/src/main/java/org/apache/doris/connector/hudi/HudiConnectorMetadata.java
index 60f0a969b7d..cfe252a098d 100644
--- 
a/fe/fe-connector/fe-connector-hudi/src/main/java/org/apache/doris/connector/hudi/HudiConnectorMetadata.java
+++ 
b/fe/fe-connector/fe-connector-hudi/src/main/java/org/apache/doris/connector/hudi/HudiConnectorMetadata.java
@@ -1374,7 +1374,7 @@ public class HudiConnectorMetadata implements 
ConnectorMetadata {
             }
         } else if (expr instanceof ConnectorComparison) {
             ConnectorComparison cmp = (ConnectorComparison) expr;
-            if (cmp.getOperator() == ConnectorComparison.Operator.EQ) {
+            if (cmp.getOperator() == ConnectorComparison.Operator.EQ && 
isScalarLiteral(cmp.getRight())) {
                 String colName = extractColumnName(cmp.getLeft());
                 String value = extractLiteralValue(cmp.getRight());
                 if (colName != null && value != null && 
partKeySet.contains(colName)) {
@@ -1383,12 +1383,15 @@ public class HudiConnectorMetadata implements 
ConnectorMetadata {
             }
         } else if (expr instanceof ConnectorIn) {
             ConnectorIn inExpr = (ConnectorIn) expr;
-            if (!inExpr.isNegated()) {
+            // Skipping an item that is not a partition value would narrow the 
list and drop the partitions
+            // that item matches, so an IN prunes only when every item is a 
scalar literal.
+            if (!inExpr.isNegated() && 
inExpr.getInList().stream().allMatch(HudiConnectorMetadata::isScalarLiteral)) {
                 String colName = extractColumnName(inExpr.getValue());
                 if (colName != null && partKeySet.contains(colName)) {
                     List<String> values = new ArrayList<>();
                     for (ConnectorExpression item : inExpr.getInList()) {
                         String val = extractLiteralValue(item);
+                        // A NULL item matches no partition.
                         if (val != null) {
                             values.add(val);
                         }
@@ -1415,6 +1418,20 @@ public class HudiConnectorMetadata implements 
ConnectorMetadata {
         return null;
     }
 
+    /**
+     * Whether {@code expr} is a literal that can stand for a partition value. 
A literal of type ARRAY, MAP or
+     * STRUCT arrives only as the operand of a CAST the engine stripped, as in 
{@code p = CAST([true] AS STRING)},
+     * and its value is not the text that cast yields (an ARRAY arrives as an 
element list), so it never prunes.
+     */
+    private static boolean isScalarLiteral(ConnectorExpression expr) {
+        if (!(expr instanceof ConnectorLiteral)) {
+            return false;
+        }
+        String typeName = ((ConnectorLiteral) expr).getType().getTypeName();
+        return !"ARRAY".equalsIgnoreCase(typeName) && 
!"MAP".equalsIgnoreCase(typeName)
+                && !"STRUCT".equalsIgnoreCase(typeName);
+    }
+
     private String extractLiteralValue(ConnectorExpression expr) {
         if (!(expr instanceof ConnectorLiteral)) {
             return null;
diff --git 
a/fe/fe-connector/fe-connector-hudi/src/test/java/org/apache/doris/connector/hudi/HudiPartitionPruningTest.java
 
b/fe/fe-connector/fe-connector-hudi/src/test/java/org/apache/doris/connector/hudi/HudiPartitionPruningTest.java
index ee032589b30..72fc31a13f6 100644
--- 
a/fe/fe-connector/fe-connector-hudi/src/test/java/org/apache/doris/connector/hudi/HudiPartitionPruningTest.java
+++ 
b/fe/fe-connector/fe-connector-hudi/src/test/java/org/apache/doris/connector/hudi/HudiPartitionPruningTest.java
@@ -28,6 +28,7 @@ import 
org.apache.doris.connector.spi.pushdown.ConnectorColumnRef;
 import org.apache.doris.connector.spi.pushdown.ConnectorComparison;
 import org.apache.doris.connector.spi.pushdown.ConnectorExpression;
 import org.apache.doris.connector.spi.pushdown.ConnectorFilterConstraint;
+import org.apache.doris.connector.spi.pushdown.ConnectorFunctionCall;
 import org.apache.doris.connector.spi.pushdown.ConnectorIn;
 import org.apache.doris.connector.spi.pushdown.ConnectorLiteral;
 import org.apache.doris.connector.spi.pushdown.FilterApplicationResult;
@@ -358,8 +359,65 @@ public class HudiPartitionPruningTest {
         Assertions.assertEquals(Collections.singletonList("1"), 
prunedPaths(result));
     }
 
+    @Test
+    public void complexLiteralIsNeverAPartitionValue() {
+        // p = CAST([TRUE] AS STRING): the engine strips the CAST, so the 
literal arrives as the element list [true]
+        // while BE renders the cast as "[1]"; a MAP or STRUCT literal arrives 
as its display text. Read as a
+        // partition value, either would prune the p=[1] partition away, and 
in an IN, skipping just that item
+        // would narrow the list to 'x'.
+        HudiConnectorMetadata metadata = metadata(
+                new FakeHmsClient(PARTITIONS), HudiTestProperties.minimal(),
+                new StubMetaClientExecutor(Arrays.asList("[1]", "x")));
+        HudiTableHandle handle = singleKeyHandle("p");
+        for (ConnectorLiteral literal : complexLiterals()) {
+            ConnectorExpression equality =
+                    new ConnectorComparison(ConnectorComparison.Operator.EQ, 
colRef("p"), literal);
+            ConnectorExpression inList = new ConnectorIn(colRef("p"), 
Arrays.asList(literal, lit("x")), false);
+            Assertions.assertFalse(metadata.applyFilter(null, handle, new 
ConnectorFilterConstraint(equality))
+                    .isPresent(), equality.toString());
+            Assertions.assertFalse(metadata.applyFilter(null, handle, new 
ConnectorFilterConstraint(inList))
+                    .isPresent(), inList.toString());
+        }
+    }
+
+    @Test
+    public void inListWithAnItemThatIsNotALiteralDoesNotPrune() {
+        // p IN (f(), 'x') with a call the planner did not fold: skipping the 
call would keep only p=x and lose the
+        // rows whose p equals what f() returns. A NULL item matches no 
partition, so the IN still prunes without it.
+        HudiConnectorMetadata metadata = metadata(
+                new FakeHmsClient(PARTITIONS), HudiTestProperties.minimal(),
+                new StubMetaClientExecutor(Arrays.asList("a", "x")));
+        HudiTableHandle handle = singleKeyHandle("p");
+        ConnectorExpression withCall = new ConnectorIn(colRef("p"), 
Arrays.asList(
+                new ConnectorFunctionCall("f", ConnectorType.of("STRING"), 
Collections.emptyList()), lit("x")), false);
+        ConnectorExpression withNull = new ConnectorIn(colRef("p"),
+                
Arrays.asList(ConnectorLiteral.ofNull(ConnectorType.of("STRING")), lit("x")), 
false);
+
+        Assertions.assertFalse(
+                metadata.applyFilter(null, handle, new 
ConnectorFilterConstraint(withCall)).isPresent());
+        Assertions.assertEquals(Collections.singletonList("x"),
+                prunedPaths(metadata.applyFilter(null, handle, new 
ConnectorFilterConstraint(withNull))));
+    }
+
     // ========== helpers ==========
 
+    private static HudiTableHandle singleKeyHandle(String partitionKey) {
+        return new HudiTableHandle.Builder("db", "t", "s3://b/t", 
"COPY_ON_WRITE")
+                .partitionKeyNames(Collections.singletonList(partitionKey))
+                .build();
+    }
+
+    /** An ARRAY, a MAP and a STRUCT literal, each with the value the engine's 
converter gives that type. */
+    private static List<ConnectorLiteral> complexLiterals() {
+        return Arrays.asList(
+                new 
ConnectorLiteral(ConnectorType.arrayOf(ConnectorType.of("BOOLEAN")),
+                        Collections.singletonList(true)),
+                new 
ConnectorLiteral(ConnectorType.mapOf(ConnectorType.of("STRING"), 
ConnectorType.of("INT")),
+                        "{\"k\":1}"),
+                new 
ConnectorLiteral(ConnectorType.structOf(Collections.singletonList("f"),
+                        Collections.singletonList(ConnectorType.of("INT"))), 
"{\"f\":1}"));
+    }
+
     private Optional<FilterApplicationResult<ConnectorTableHandle>> 
applyFilter(
             HudiTableHandle handle, ConnectorExpression expr) {
         // Default (use_hive_sync_partition=false) -> the non-hive-sync 
branch, whose candidate source is the Hudi
diff --git 
a/fe/fe-connector/fe-connector-jdbc/src/main/java/org/apache/doris/connector/jdbc/JdbcQueryBuilder.java
 
b/fe/fe-connector/fe-connector-jdbc/src/main/java/org/apache/doris/connector/jdbc/JdbcQueryBuilder.java
index cbc2828041a..c8f8b3c75fc 100644
--- 
a/fe/fe-connector/fe-connector-jdbc/src/main/java/org/apache/doris/connector/jdbc/JdbcQueryBuilder.java
+++ 
b/fe/fe-connector/fe-connector-jdbc/src/main/java/org/apache/doris/connector/jdbc/JdbcQueryBuilder.java
@@ -841,6 +841,10 @@ public final class JdbcQueryBuilder {
             return "NULL";
         }
         Object val = lit.getValue();
+        if (val instanceof List) {
+            // An ARRAY literal has no spelling the remote dialects share, and 
its elements' text is not SQL.
+            return null;
+        }
         if ("UUID".equalsIgnoreCase(lit.getType().getTypeName())
                 && (dbType == JdbcDbType.TRINO || dbType == 
JdbcDbType.PRESTO)) {
             // These engines do not implicitly coerce VARCHAR literals when 
comparing UUID columns.
diff --git 
a/fe/fe-connector/fe-connector-jdbc/src/test/java/org/apache/doris/connector/jdbc/JdbcQueryBuilderTest.java
 
b/fe/fe-connector/fe-connector-jdbc/src/test/java/org/apache/doris/connector/jdbc/JdbcQueryBuilderTest.java
index 2c27b29c59f..a611ba8776c 100644
--- 
a/fe/fe-connector/fe-connector-jdbc/src/test/java/org/apache/doris/connector/jdbc/JdbcQueryBuilderTest.java
+++ 
b/fe/fe-connector/fe-connector-jdbc/src/test/java/org/apache/doris/connector/jdbc/JdbcQueryBuilderTest.java
@@ -393,6 +393,33 @@ class JdbcQueryBuilderTest {
         }
     }
 
+    @Test
+    void testArrayLiteralsRemainLocalWithoutLimit() {
+        ConnectorType stringArray = ConnectorType.arrayOf(STRING_TYPE);
+        ConnectorColumnRef tags = new ConnectorColumnRef("tags", stringArray);
+        // Rendered as text, these elements would reach the remote SQL 
unquoted.
+        ConnectorLiteral array = new ConnectorLiteral(stringArray, 
Arrays.asList("a, b", "x') OR ('1'='1"));
+        ConnectorExpression comparison = new 
ConnectorComparison(ConnectorComparison.Operator.EQ, tags, array);
+        ConnectorExpression overlap = new 
ConnectorFunctionCall("arrays_overlap", BOOLEAN_TYPE,
+                Arrays.asList(tags, array));
+        // MySQL pushes any function not on its deny list, arrays_overlap 
included.
+        JdbcFunctionPushdownConfig config = 
JdbcFunctionPushdownConfig.create(JdbcDbType.MYSQL, null, true);
+        for (JdbcQueryBuilder builder : Arrays.asList(new 
JdbcQueryBuilder(JdbcDbType.MYSQL, config,
+                        Collections.emptyMap()), new 
JdbcQueryBuilder(JdbcDbType.POSTGRESQL),
+                new JdbcQueryBuilder(JdbcDbType.CLICKHOUSE), new 
JdbcQueryBuilder(JdbcDbType.TRINO))) {
+            for (ConnectorExpression filter : Arrays.asList(comparison, 
overlap, new ConnectorNot(comparison))) {
+                String sql = builder.buildQuery(DB, TABLE, 
Collections.emptyList(), Optional.of(filter), 1);
+                Assertions.assertFalse(sql.contains(" WHERE "), sql);
+                Assertions.assertFalse(sql.contains("LIMIT"), sql);
+            }
+            String sql = builder.buildQuery(DB, TABLE, 
Collections.emptyList(), Optional.of(
+                    new ConnectorAnd(Arrays.asList(comparison, 
simpleComparison("id", 1)))), 1);
+            Assertions.assertTrue(sql.contains(" WHERE "), sql);
+            Assertions.assertFalse(sql.contains("a, b") || 
sql.contains("'1'='1"), sql);
+            Assertions.assertFalse(sql.contains("LIMIT"), sql);
+        }
+    }
+
     // --- LIMIT pushdown tests ---
 
     @Test
diff --git 
a/fe/fe-connector/fe-connector-spi/src/main/java/org/apache/doris/connector/spi/ConnectorPushdownOps.java
 
b/fe/fe-connector/fe-connector-spi/src/main/java/org/apache/doris/connector/spi/ConnectorPushdownOps.java
index add1b46ccdf..4c6239ed686 100644
--- 
a/fe/fe-connector/fe-connector-spi/src/main/java/org/apache/doris/connector/spi/ConnectorPushdownOps.java
+++ 
b/fe/fe-connector/fe-connector-spi/src/main/java/org/apache/doris/connector/spi/ConnectorPushdownOps.java
@@ -54,9 +54,10 @@ public interface ConnectorPushdownOps {
      * CAST expressions, including CAST subclasses such as TRY_CAST.
      *
      * <p><b>This switch governs ONE of the two pushdown paths.</b> Returning 
{@code false} makes the engine
-     * drop CAST-containing conjuncts from the RESIDUAL predicate it builds 
for the scan node. The
-     * {@link #applyFilter} path never consults it: there the engine converts 
every conjunct and hands the
-     * result to the connector regardless of what this method answers.</p>
+     * drop CAST-containing conjuncts from the RESIDUAL predicate it builds 
for the scan node; a conjunct
+     * holding a TIMESTAMPTZ cast or a complex-kind cast (Rule 4 of the {@code 
pushdown} package) is dropped
+     * from it whatever this method answers. The {@link #applyFilter} path 
never consults it: there the engine
+     * converts every conjunct and hands the result to the connector 
regardless of what this method answers.</p>
      *
      * <p><b>And on either path a CAST does not arrive as a CAST.</b> The 
forward converter unwraps it and
      * pushes the child expression, so {@code CAST(dt AS INT) = 20240101} 
reaches the connector as
diff --git 
a/fe/fe-connector/fe-connector-spi/src/main/java/org/apache/doris/connector/spi/pushdown/ConnectorLiteral.java
 
b/fe/fe-connector/fe-connector-spi/src/main/java/org/apache/doris/connector/spi/pushdown/ConnectorLiteral.java
index 6ed5c75671f..de0d48fabb3 100644
--- 
a/fe/fe-connector/fe-connector-spi/src/main/java/org/apache/doris/connector/spi/pushdown/ConnectorLiteral.java
+++ 
b/fe/fe-connector/fe-connector-spi/src/main/java/org/apache/doris/connector/spi/pushdown/ConnectorLiteral.java
@@ -29,9 +29,10 @@ import java.util.Objects;
 /**
  * A literal value expression.
  *
- * <p>The value is a standard Java type. The engine produces exactly these 
eight shapes — see the package
+ * <p>The value is a standard Java type. The engine produces exactly these 
nine shapes — see the package
  * javadoc (Rule 4) for the full Doris-type-to-Java-class table: {@code null}, 
{@code Boolean}, {@code Long},
- * {@code Double}, {@code BigDecimal}, {@code String}, {@code LocalDate}, 
{@code LocalDateTime}.</p>
+ * {@code Double}, {@code BigDecimal}, {@code String}, {@code LocalDate}, 
{@code LocalDateTime}, and for an
+ * {@code ARRAY} an unmodifiable {@code List} whose elements take these same 
shapes.</p>
  *
  * <p>Two consequences worth stating outright, because both have produced 
wrong connector code:
  * <b>{@code Integer} never arrives</b> (every integral type, {@code TINYINT} 
through {@code BIGINT}, is a
diff --git 
a/fe/fe-connector/fe-connector-spi/src/main/java/org/apache/doris/connector/spi/pushdown/package-info.java
 
b/fe/fe-connector/fe-connector-spi/src/main/java/org/apache/doris/connector/spi/pushdown/package-info.java
index 62ee088c117..81b46ad6109 100644
--- 
a/fe/fe-connector/fe-connector-spi/src/main/java/org/apache/doris/connector/spi/pushdown/package-info.java
+++ 
b/fe/fe-connector/fe-connector-spi/src/main/java/org/apache/doris/connector/spi/pushdown/package-info.java
@@ -109,10 +109,19 @@
  * <li>The {@code Optional<ConnectorExpression> filter} handed to {@code 
ConnectorScanPlanProvider.planScan}
  *     and {@code getScanNodePropertiesResult} comes from {@code 
PluginDrivenScanNode.buildRemainingFilter},
  *     which DOES drop conjuncts containing a CAST when
- *     {@link 
org.apache.doris.connector.spi.ConnectorPushdownOps#supportsCastPredicatePushdown}
 is false.</li>
+ *     {@link 
org.apache.doris.connector.spi.ConnectorPushdownOps#supportsCastPredicatePushdown}
 is false, and
+ *     always drops a conjunct holding a TIMESTAMPTZ cast or a complex-kind 
cast (below).</li>
  * </ul>
  *
- * <p><b>Literal value domain.</b> {@link ConnectorLiteral#getValue()} is one 
of exactly eight Java shapes.
+ * <p><b>Complex-kind casts.</b> A CAST into or out of ARRAY, MAP or STRUCT, 
other than one between two types of
+ * the same kind, changes the shape of the value, so the operand that arrives 
in its place is not what the cast
+ * yields: {@code CAST([true] AS STRING)} is the text {@code [1]} in Doris, 
but its operand is the element list
+ * {@code [true]}. Of the two paths, only {@code applyFilter} receives such a 
conjunct. There a literal of type
+ * ARRAY, MAP or STRUCT can face a column of a scalar type, as in {@code p = 
[true]} or {@code p IN ([true], 'x')}:
+ * it is not a value of that column, so do not render it as text, and do not 
skip it alone in an IN list, which
+ * would narrow the list. Leave such a predicate to Doris.</p>
+ *
+ * <p><b>Literal value domain.</b> {@link ConnectorLiteral#getValue()} is one 
of exactly nine Java shapes.
  * Note that {@code Integer} is never produced and that {@code LARGEINT} 
arrives as a decimal
  * {@code String}:</p>
  * <table border="1">
@@ -126,7 +135,9 @@
  * <tr><td>CHAR / VARCHAR / STRING</td><td>{@code String}</td></tr>
  * <tr><td>DATE / DATEV2</td><td>{@code LocalDate}</td></tr>
  * <tr><td>DATETIME / DATETIMEV2</td><td>{@code LocalDateTime}</td></tr>
- * <tr><td>anything else, incl. LARGEINT, IPV4/IPV6, JSON</td>
+ * <tr><td>ARRAY</td><td>an unmodifiable {@code List} of the element values, 
each in the shape this table gives
+ *     its element type: {@code null} for a NULL element, a nested {@code 
List} for a nested array</td></tr>
+ * <tr><td>anything else, incl. LARGEINT, IPV4/IPV6, JSON, MAP, STRUCT</td>
  *     <td>{@code String} from {@code Expr.getStringValue()}</td></tr>
  * </table>
  *
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/connector/converter/ExprToConnectorExpressionConverter.java
 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/connector/converter/ExprToConnectorExpressionConverter.java
index 8eccb3b9935..d673b803d1a 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/connector/converter/ExprToConnectorExpressionConverter.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/connector/converter/ExprToConnectorExpressionConverter.java
@@ -18,6 +18,7 @@
 package org.apache.doris.datasource.connector.converter;
 
 import org.apache.doris.analysis.ArithmeticExpr;
+import org.apache.doris.analysis.ArrayLiteral;
 import org.apache.doris.analysis.BetweenPredicate;
 import org.apache.doris.analysis.BinaryPredicate;
 import org.apache.doris.analysis.BoolLiteral;
@@ -286,7 +287,7 @@ public final class ExprToConnectorExpressionConverter {
         return new ConnectorColumnRef(colName, ct);
     }
 
-    private static ConnectorExpression convertLiteral(LiteralExpr literal) {
+    private static ConnectorLiteral convertLiteral(LiteralExpr literal) {
         ConnectorType ct = typeToConnectorType(literal.getType());
         if (literal instanceof NullLiteral) {
             return ConnectorLiteral.ofNull(ct);
@@ -302,12 +303,26 @@ public final class ExprToConnectorExpressionConverter {
             return new ConnectorLiteral(ct, ((StringLiteral) 
literal).getValue());
         } else if (literal instanceof DateLiteral) {
             return convertDateLiteral((DateLiteral) literal, ct);
+        } else if (literal instanceof ArrayLiteral) {
+            return new ConnectorLiteral(ct, arrayElements((ArrayLiteral) 
literal));
         } else {
             return new ConnectorLiteral(ct, literal.getStringValue());
         }
     }
 
-    private static ConnectorExpression convertDateLiteral(DateLiteral dl, 
ConnectorType ct) {
+    /**
+     * The element values of an ARRAY literal, each in the shape it would have 
as a literal of its own:
+     * {@code null} for a NULL element, a nested list for a nested array.
+     */
+    private static List<Object> arrayElements(ArrayLiteral literal) {
+        List<Object> elements = new ArrayList<>(literal.getChildren().size());
+        for (Expr element : literal.getChildren()) {
+            elements.add(convertLiteral((LiteralExpr) element).getValue());
+        }
+        return Collections.unmodifiableList(elements);
+    }
+
+    private static ConnectorLiteral convertDateLiteral(DateLiteral dl, 
ConnectorType ct) {
         Type dorisType = dl.getType();
         if (dorisType.equals(Type.DATE) || dorisType.equals(Type.DATEV2)) {
             LocalDate ld = LocalDate.of(
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/scan/PluginDrivenScanNode.java
 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/scan/PluginDrivenScanNode.java
index 39f04ed3883..c17ce922e33 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/datasource/scan/PluginDrivenScanNode.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/datasource/scan/PluginDrivenScanNode.java
@@ -2959,7 +2959,8 @@ public class PluginDrivenScanNode extends 
FileQueryScanNode {
     /**
      * Builds the remaining filter expression from unconsumed conjuncts.
      * If no conjuncts remain, returns {@link Optional#empty()}.
-     * Filters out CAST-containing predicates when the connector does not 
support CAST pushdown.
+     * Filters out CAST-containing predicates when the connector does not 
support CAST pushdown, and
+     * TIMESTAMPTZ and complex-kind casts ({@link #containsComplexKindCast}) 
for every connector.
      */
     private Optional<ConnectorExpression> buildRemainingFilter() {
         if (conjuncts == null || conjuncts.isEmpty()) {
@@ -2972,8 +2973,10 @@ public class PluginDrivenScanNode extends 
FileQueryScanNode {
         for (int i = 0; i < conjuncts.size(); i++) {
             Expr conjunct = conjuncts.get(i);
             // The neutral converter strips CASTs. Instant casts can depend on 
the Doris session
-            // timezone, so both the predicate and its LIMIT must stay local 
before type information is lost.
-            if ((!supportsCast && containsCastExpr(conjunct)) || 
containsTimestampTzCast(conjunct)) {
+            // timezone, and a cast into or out of a complex type changes the 
shape of the value, so in
+            // both cases the predicate and its LIMIT must stay local before 
type information is lost.
+            if ((!supportsCast && containsCastExpr(conjunct)) || 
containsTimestampTzCast(conjunct)
+                    || containsComplexKindCast(conjunct)) {
                 continue;
             }
             pushableConjuncts.add(conjunct);
@@ -2995,6 +2998,25 @@ public class PluginDrivenScanNode extends 
FileQueryScanNode {
         return !casts.isEmpty();
     }
 
+    /**
+     * Whether {@code expr} holds a CAST into or out of ARRAY, MAP or STRUCT, 
other than one between two types of
+     * the same kind. Such a cast changes the shape of the value, so the 
operand the converter hands over in its
+     * place is not what the cast yields: {@code CAST([true] AS STRING)} is 
the text {@code [1]} in Doris, but its
+     * operand reaches the connector as the element list {@code [true]}, and 
{@code CAST(arr AS STRING) = '[1]'}
+     * reaches it as {@code arr = '[1]'}.
+     */
+    static boolean containsComplexKindCast(Expr expr) {
+        List<Expr> casts = new ArrayList<>();
+        expr.collect(node -> node instanceof CastExpr
+                && changesComplexKind(node.getChild(0).getType(), 
node.getType()), casts);
+        return !casts.isEmpty();
+    }
+
+    private static boolean changesComplexKind(Type from, Type to) {
+        return from.isArrayType() != to.isArrayType() || from.isMapType() != 
to.isMapType()
+                || from.isStructType() != to.isStructType();
+    }
+
     static boolean containsCastExpr(Expr expr) {
         List<Expr> castExprs = new ArrayList<>();
         expr.collect(node -> node instanceof CastExpr, castExprs);
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/datasource/connector/converter/ExprToConnectorExpressionConverterTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/datasource/connector/converter/ExprToConnectorExpressionConverterTest.java
new file mode 100644
index 00000000000..efb73b1f743
--- /dev/null
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/datasource/connector/converter/ExprToConnectorExpressionConverterTest.java
@@ -0,0 +1,125 @@
+// 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.datasource.connector.converter;
+
+import org.apache.doris.connector.spi.pushdown.ConnectorExpression;
+import org.apache.doris.connector.spi.pushdown.ConnectorLiteral;
+import org.apache.doris.nereids.trees.expressions.literal.ArrayLiteral;
+import org.apache.doris.nereids.trees.expressions.literal.BigIntLiteral;
+import org.apache.doris.nereids.trees.expressions.literal.BooleanLiteral;
+import org.apache.doris.nereids.trees.expressions.literal.DateTimeV2Literal;
+import org.apache.doris.nereids.trees.expressions.literal.DateV2Literal;
+import org.apache.doris.nereids.trees.expressions.literal.DecimalV3Literal;
+import org.apache.doris.nereids.trees.expressions.literal.DoubleLiteral;
+import org.apache.doris.nereids.trees.expressions.literal.IntegerLiteral;
+import org.apache.doris.nereids.trees.expressions.literal.LargeIntLiteral;
+import org.apache.doris.nereids.trees.expressions.literal.Literal;
+import org.apache.doris.nereids.trees.expressions.literal.NullLiteral;
+import org.apache.doris.nereids.trees.expressions.literal.VarcharLiteral;
+import org.apache.doris.nereids.types.ArrayType;
+import org.apache.doris.nereids.types.DateTimeV2Type;
+import org.apache.doris.nereids.types.IntegerType;
+import org.apache.doris.nereids.types.VarcharType;
+
+import com.google.common.collect.ImmutableList;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Literal encoding of {@link ExprToConnectorExpressionConverter}. The 
literals start as Nereids
+ * literals and reach the converter through {@code toLegacyLiteral}, as they 
do when the scan node
+ * translates its conjuncts.
+ */
+public class ExprToConnectorExpressionConverterTest {
+
+    private static ConnectorLiteral convert(Literal literal) {
+        ConnectorExpression converted = 
ExprToConnectorExpressionConverter.convert(literal.toLegacyLiteral());
+        Assertions.assertInstanceOf(ConnectorLiteral.class, converted);
+        return (ConnectorLiteral) converted;
+    }
+
+    @Test
+    public void arrayLiteralCarriesItsElementsRatherThanItsText() {
+        // Rendered as text, this array reads "[red, a, b, it's]": three 
elements or four, and no way
+        // to tell which.
+        ConnectorLiteral array = convert(new ArrayLiteral(ImmutableList.of(
+                new VarcharLiteral("red"), new VarcharLiteral("a, b"), new 
VarcharLiteral("it's"))));
+
+        Assertions.assertEquals("ARRAY", array.getType().getTypeName());
+        Assertions.assertEquals("VARCHAR", 
array.getType().getChildren().get(0).getTypeName());
+        Assertions.assertEquals(Arrays.asList("red", "a, b", "it's"), 
array.getValue());
+    }
+
+    @Test
+    public void elementsTakeTheShapeTheyWouldHaveAsLiteralsOfTheirOwn() {
+        List<Literal> scalars = ImmutableList.of(
+                BooleanLiteral.of(true),
+                new IntegerLiteral(7),
+                new BigIntLiteral(Long.MIN_VALUE),
+                new LargeIntLiteral(new 
BigInteger("170141183460469231731687303715884105727")),
+                new DoubleLiteral(1.5),
+                new DecimalV3Literal(new BigDecimal("12.50")),
+                new DateV2Literal("2024-01-02"),
+                new DateTimeV2Literal(DateTimeV2Type.of(6), "2024-01-02 
03:04:05.123456"));
+        List<Class<?>> shapes = Arrays.asList(Boolean.class, Long.class, 
Long.class, String.class,
+                Double.class, BigDecimal.class, LocalDate.class, 
LocalDateTime.class);
+
+        for (int i = 0; i < scalars.size(); i++) {
+            Literal scalar = scalars.get(i);
+            Object element = ((List<?>) convert(new 
ArrayLiteral(ImmutableList.of(scalar))).getValue()).get(0);
+            Assertions.assertEquals(convert(scalar).getValue(), element, 
scalar.toString());
+            Assertions.assertEquals(shapes.get(i), element.getClass(), 
scalar.toString());
+        }
+        Assertions.assertEquals(LocalDateTime.of(2024, 1, 2, 3, 4, 5, 
123_456_000),
+                ((List<?>) convert(new 
ArrayLiteral(ImmutableList.of(scalars.get(7)))).getValue()).get(0));
+    }
+
+    @Test
+    public void nullElementsAndNestedArraysKeepTheirStructure() {
+        ArrayType intArray = ArrayType.of(IntegerType.INSTANCE);
+        ConnectorLiteral withNull = convert(new ArrayLiteral(ImmutableList.of(
+                new VarcharLiteral("red"), new 
NullLiteral(VarcharType.SYSTEM_DEFAULT))));
+        Assertions.assertEquals(Arrays.asList("red", null), 
withNull.getValue());
+
+        ConnectorLiteral nested = convert(new ArrayLiteral(ImmutableList.of(
+                new ArrayLiteral(ImmutableList.of(new IntegerLiteral(1), new 
IntegerLiteral(2)), intArray),
+                new ArrayLiteral(ImmutableList.of(), intArray),
+                new NullLiteral(intArray)), ArrayType.of(intArray)));
+        Assertions.assertEquals("ARRAY", 
nested.getType().getChildren().get(0).getTypeName());
+        Assertions.assertEquals(Arrays.asList(Arrays.asList(1L, 2L), 
Collections.emptyList(), null),
+                nested.getValue());
+    }
+
+    @Test
+    public void elementListIsUnmodifiableAndANullArrayIsStillANullLiteral() {
+        List<?> elements = (List<?>) convert(new 
ArrayLiteral(ImmutableList.of(new IntegerLiteral(1)))).getValue();
+        Assertions.assertThrows(UnsupportedOperationException.class, 
elements::clear);
+
+        ConnectorLiteral nullArray = convert(new 
NullLiteral(ArrayType.of(IntegerType.INSTANCE)));
+        Assertions.assertTrue(nullArray.isNull());
+        Assertions.assertEquals("ARRAY", nullArray.getType().getTypeName());
+    }
+}
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/datasource/scan/PluginDrivenScanNodeCastPredicateTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/datasource/scan/PluginDrivenScanNodeCastPredicateTest.java
index 1d7252a43de..2427bf14eaa 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/datasource/scan/PluginDrivenScanNodeCastPredicateTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/datasource/scan/PluginDrivenScanNodeCastPredicateTest.java
@@ -48,6 +48,11 @@ import java.util.Optional;
  * scan. branch-4.x fixed the same row loss inside its Paimon predicate 
converter (#67933); master enforces
  * it in {@code buildRemainingFilter}, which had no direct test.</p>
  *
+ * <p>A cast into or out of ARRAY, MAP or STRUCT stays in Doris even for a 
connector that accepts casts: the
+ * stripped operand has another shape than the cast's result, so {@code code = 
CAST([true] AS STRING)} would
+ * reach the connector as {@code code} against the element list {@code 
[true]}, while Doris compares with
+ * {@code [1]}.</p>
+ *
  * <p>The conjuncts come from planning real queries, so the shapes are the 
ones Nereids produces. The
  * filter is then built through the real private method on a {@code 
CALLS_REAL_METHODS} node with only the
  * connector metadata injected.</p>
@@ -58,7 +63,8 @@ public class PluginDrivenScanNodeCastPredicateTest extends 
TestWithFeService {
     protected void runBeforeAll() throws Exception {
         FeConstants.runningUnitTest = true;
         createDatabase("db1");
-        createTables("create table db1.cast_predicates (id int, code string, 
amount decimal(10, 2))"
+        createTables("create table db1.cast_predicates (id int, code string, 
amount decimal(10, 2),"
+                + " arr array<int>, m map<string, int>, s struct<f:int>)"
                 + " distributed by hash(id) properties('replication_num' = 
'1')");
     }
 
@@ -130,6 +136,38 @@ public class PluginDrivenScanNodeCastPredicateTest extends 
TestWithFeService {
         Assertions.assertNull(Deencapsulation.getField(node, 
"filteredToOriginalIndex"));
     }
 
+    @ParameterizedTest
+    @ValueSource(strings = {"code = cast([true] as string)", "code in 
(cast([true] as string), 'x')",
+            "code like cast(['a%'] as string)", "cast(arr as string) = '[1]'", 
"arr = cast('[1]' as array<int>)",
+            "cast(m as string) = '{\"k\":1}'", "cast(s as string) = 
'{\"f\":1}'"})
+    public void 
complexKindCastConjunctsStayInDorisWhenTheConnectorAcceptsCasts(String 
predicate) throws Exception {
+        List<Expr> conjuncts = planConjuncts(predicate);
+        // Precondition: the planner does not fold the CAST away (FE cannot 
fold a cast between kinds).
+        
Assertions.assertTrue(conjuncts.stream().anyMatch(PluginDrivenScanNode::containsCastExpr),
 predicate);
+        List<Expr> before = Expr.cloneList(conjuncts);
+
+        PluginDrivenScanNode node = nodeWith(conjuncts, true);
+        Optional<ConnectorExpression> filter = Deencapsulation.invoke(node, 
"buildRemainingFilter");
+
+        Assertions.assertFalse(filter.isPresent(), predicate);
+        Assertions.assertEquals(Collections.emptyList(),
+                Deencapsulation.getField(node, "filteredToOriginalIndex"), 
predicate);
+        Assertions.assertEquals(before, conjuncts, predicate);
+    }
+
+    @Test
+    public void arrayToArrayCastIsPushedWhenTheConnectorAcceptsCasts() throws 
Exception {
+        List<Expr> conjuncts = planConjuncts("cast(arr as array<bigint>) = [1, 
2]");
+        
Assertions.assertTrue(conjuncts.stream().anyMatch(PluginDrivenScanNode::containsCastExpr));
+
+        PluginDrivenScanNode node = nodeWith(conjuncts, true);
+        Optional<ConnectorExpression> filter = Deencapsulation.invoke(node, 
"buildRemainingFilter");
+
+        // A cast between two ARRAY types keeps the value a list, so it is an 
ordinary cast.
+        Assertions.assertTrue(filter.isPresent());
+        Assertions.assertNull(Deencapsulation.getField(node, 
"filteredToOriginalIndex"));
+    }
+
     private List<Expr> planConjuncts(String predicate) throws Exception {
         StmtExecutor executor = new StmtExecutor(connectContext,
                 "select * from db1.cast_predicates where " + predicate);
diff --git 
a/regression-test/data/external_table_p0/jdbc/test_jdbc_array_literal_predicate.out
 
b/regression-test/data/external_table_p0/jdbc/test_jdbc_array_literal_predicate.out
new file mode 100644
index 00000000000..393c92be0d0
--- /dev/null
+++ 
b/regression-test/data/external_table_p0/jdbc/test_jdbc_array_literal_predicate.out
@@ -0,0 +1,57 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !doris_eq --
+1
+
+-- !doris_ne --
+2
+3
+4
+
+-- !doris_null_element --
+3
+
+-- !doris_int --
+1
+
+-- !doris_nested --
+1
+
+-- !doris_arrays_overlap --
+1
+
+-- !doris_array_contains_or --
+1
+
+-- !doris_and --
+1
+
+-- !doris_or --
+1
+2
+
+-- !doris_limit --
+1
+
+-- !pg_text --
+2
+
+-- !pg_int --
+2
+
+-- !pg_ne --
+3
+
+-- !pg_null_element --
+3
+
+-- !pg_and --
+2
+
+-- !clickhouse_string --
+1
+
+-- !clickhouse_ne --
+
+-- !clickhouse_int --
+1
+
diff --git 
a/regression-test/data/external_table_p2/es/test_es_array_literal_predicate.out 
b/regression-test/data/external_table_p2/es/test_es_array_literal_predicate.out
new file mode 100644
index 00000000000..c4804625b2f
--- /dev/null
+++ 
b/regression-test/data/external_table_p2/es/test_es_array_literal_predicate.out
@@ -0,0 +1,43 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !es7_keyword_eq --
+3.14
+4
+5
+6
+6
+
+-- !es7_keyword_ne --
+
+-- !es7_long_eq --
+3.14
+4
+5
+6
+6
+
+-- !es7_and --
+5
+6
+6
+
+-- !es8_keyword_eq --
+3.14
+4
+5
+6
+6
+
+-- !es8_keyword_ne --
+
+-- !es8_long_eq --
+3.14
+4
+5
+6
+6
+
+-- !es8_and --
+5
+6
+6
+
diff --git 
a/regression-test/suites/external_table_p0/jdbc/test_jdbc_array_literal_predicate.groovy
 
b/regression-test/suites/external_table_p0/jdbc/test_jdbc_array_literal_predicate.groovy
new file mode 100644
index 00000000000..65cd4e7cc74
--- /dev/null
+++ 
b/regression-test/suites/external_table_p0/jdbc/test_jdbc_array_literal_predicate.groovy
@@ -0,0 +1,157 @@
+// 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.
+
+// A JDBC catalog evaluates in Doris a filter that compares a column with an 
ARRAY constant or passes one to a
+// function, because the remote dialects share no spelling for an ARRAY 
constant. The constant used to reach the
+// source as text such as '[a, b]': a remote Doris read it back as other 
elements and lost rows, and PostgreSQL
+// and ClickHouse rejected it. The other conjuncts still reach the source; 
LIMIT stays in Doris with the filter.
+suite("test_jdbc_array_literal_predicate", "p0,external") {
+    String jdbcUser = context.config.jdbcUser
+    String jdbcPassword = context.config.jdbcPassword
+    String enabled = context.config.otherConfigs.get("enableJdbcTest")
+    String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
+    String s3_endpoint = getS3Endpoint()
+    String bucket = getS3BucketName()
+    String driver_prefix = 
"https://${bucket}.${s3_endpoint}/regression/jdbc_driver";
+
+    // The source is this Doris itself, whose ARRAY columns the catalog reads 
back as ARRAY.
+    sql """drop table if exists array_literal_source"""
+    sql """create table array_literal_source (
+            id int, tags array<string>, nums array<int>, nested 
array<array<int>>)
+        duplicate key(id) distributed by hash(id) buckets 1 
properties("replication_num" = "1")"""
+    sql """insert into array_literal_source values
+        (1, ['a, b'], [1, 2], [[1, 2], [3]]),
+        (2, ['a', 'b'], [1, 2, 3], [[1], [2, 3]]),
+        (3, ['red', null], [null, 4], []),
+        (4, [], [], null),
+        (5, null, null, null)"""
+
+    sql """drop catalog if exists test_jdbc_array_literal_predicate_doris"""
+    sql """create catalog test_jdbc_array_literal_predicate_doris properties (
+        "type" = "jdbc",
+        "user" = "${jdbcUser}",
+        "password" = "${jdbcPassword}",
+        "jdbc_url" = "${context.config.jdbcUrl}",
+        "driver_url" = "${driver_prefix}/mysql-connector-j-8.4.0.jar",
+        "driver_class" = "com.mysql.cj.jdbc.Driver"
+    )"""
+    sql """switch test_jdbc_array_literal_predicate_doris"""
+    sql """use ${context.dbName}"""
+
+    // An element may contain ", ": the text '[a, b]' read back as two 
elements, so row 1 was lost.
+    order_qt_doris_eq """select id from array_literal_source where tags = ['a, 
b']"""
+    order_qt_doris_ne """select id from array_literal_source where tags != 
['a, b']"""
+    order_qt_doris_null_element """select id from array_literal_source where 
tags = ['red', null]"""
+    order_qt_doris_int """select id from array_literal_source where nums = [1, 
2]"""
+    order_qt_doris_nested """select id from array_literal_source where nested 
= [[1, 2], [3]]"""
+    explain {
+        sql """select id from array_literal_source where tags = ['a, b']"""
+        contains "QUERY: SELECT `id`, `tags` FROM"
+        notContains "WHERE"
+    }
+
+    // As a function argument the text made the source fail: 
arrays_overlap(ARRAY<TEXT>, VARCHAR) has no signature.
+    order_qt_doris_arrays_overlap """select id from array_literal_source where 
arrays_overlap(tags, ['a, b', 'zz'])"""
+    explain {
+        sql """select id from array_literal_source where arrays_overlap(tags, 
['a, b', 'zz'])"""
+        contains "QUERY: SELECT `id`, `tags` FROM"
+        notContains "WHERE"
+    }
+    // The planner turns three or more ORed array_contains into arrays_overlap 
with an ARRAY constant.
+    order_qt_doris_array_contains_or """select id from array_literal_source
+        where array_contains(tags, 'a, b') or array_contains(tags, 'x') or 
array_contains(tags, 'y')"""
+    explain {
+        sql """select id from array_literal_source
+            where array_contains(tags, 'a, b') or array_contains(tags, 'x') or 
array_contains(tags, 'y')"""
+        contains "PREDICATES: arrays_overlap("
+        notContains "WHERE"
+    }
+
+    // The source still filters on another conjunct; an OR that contains the 
comparison stays in Doris as a whole.
+    order_qt_doris_and """select id from array_literal_source where tags = 
['a, b'] and id = 1"""
+    explain {
+        sql """select id from array_literal_source where tags = ['a, b'] and 
id = 1"""
+        contains "WHERE (`id` = 1)"
+        notContains "`tags` ="
+    }
+    order_qt_doris_or """select id from array_literal_source where tags = ['a, 
b'] or id = 2"""
+    explain {
+        sql """select id from array_literal_source where tags = ['a, b'] or id 
= 2"""
+        contains "QUERY: SELECT `id`, `tags` FROM"
+        notContains "WHERE"
+    }
+
+    // The source would stop after the rows the filter drops, so LIMIT is not 
pushed either.
+    order_qt_doris_limit """select id from array_literal_source where tags = 
['a, b'] limit 1"""
+    explain {
+        sql """select id from array_literal_source where tags = ['a, b'] limit 
1"""
+        contains "QUERY: SELECT `id`, `tags` FROM"
+        notContains "WHERE"
+        notContains " LIMIT "
+    }
+    sql """switch internal"""
+
+    if (enabled != null && enabled.equalsIgnoreCase("true")) {
+        String pg_port = context.config.otherConfigs.get("pg_14_port")
+        sql """drop catalog if exists test_jdbc_array_literal_predicate_pg"""
+        sql """create catalog test_jdbc_array_literal_predicate_pg properties (
+            "type" = "jdbc",
+            "user" = "postgres",
+            "password" = "123456",
+            "jdbc_url" = 
"jdbc:postgresql://${externalEnvIp}:${pg_port}/postgres?currentSchema=doris_test&useSSL=false",
+            "driver_url" = "${driver_prefix}/postgresql-42.5.0.jar",
+            "driver_class" = "org.postgresql.Driver"
+        )"""
+        sql """switch test_jdbc_array_literal_predicate_pg"""
+        sql """use catalog_pg_test"""
+        // PostgreSQL rejected the text: malformed array literal: "[hello, 
world]".
+        order_qt_pg_text """select id from test_array_null where text_arr = 
['hello', 'world']"""
+        order_qt_pg_int """select id from test_array_null where int_arr = [1, 
2, 3]"""
+        order_qt_pg_ne """select id from test_array_null where varchar_arr != 
['a', 'b']"""
+        order_qt_pg_null_element """select id from test_array_null where 
text_arr = ['foo', null]"""
+        order_qt_pg_and """select id from test_array_null where int_arr = [1, 
2, 3] and id = 2"""
+        explain {
+            sql """select id from test_array_null where int_arr = [1, 2, 3] 
and id = 2"""
+            contains "WHERE (\"id\" = 2)"
+            notContains "\"int_arr\" ="
+        }
+        sql """switch internal"""
+
+        String clickhouse_port = 
context.config.otherConfigs.get("clickhouse_22_port")
+        sql """drop catalog if exists 
test_jdbc_array_literal_predicate_clickhouse"""
+        sql """create catalog test_jdbc_array_literal_predicate_clickhouse 
properties (
+            "type" = "jdbc",
+            "user" = "default",
+            "password" = "123456",
+            "jdbc_url" = 
"jdbc:clickhouse://${externalEnvIp}:${clickhouse_port}/doris_test",
+            "driver_url" = "${driver_prefix}/clickhouse-jdbc-0.4.2-all.jar",
+            "driver_class" = "com.clickhouse.jdbc.ClickHouseDriver"
+        )"""
+        sql """switch test_jdbc_array_literal_predicate_clickhouse"""
+        sql """use doris_test"""
+        // ClickHouse could not read the text as Array(String): expected 
opening quote.
+        order_qt_clickhouse_string """select id from arr where arr24 = 
['string']"""
+        order_qt_clickhouse_ne """select id from arr where arr24 != 
['string']"""
+        order_qt_clickhouse_int """select id from arr where arr8 = [1]"""
+        explain {
+            sql """select id from arr where arr24 = ['string']"""
+            contains "QUERY: SELECT \"id\", \"arr24\" FROM"
+            notContains "WHERE"
+        }
+        sql """switch internal"""
+    }
+}
diff --git 
a/regression-test/suites/external_table_p2/es/test_es_array_literal_predicate.groovy
 
b/regression-test/suites/external_table_p2/es/test_es_array_literal_predicate.groovy
new file mode 100644
index 00000000000..61286d85a1e
--- /dev/null
+++ 
b/regression-test/suites/external_table_p2/es/test_es_array_literal_predicate.groovy
@@ -0,0 +1,71 @@
+// 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.
+
+// An ES catalog evaluates in Doris a comparison between an ARRAY column and 
an ARRAY constant, because a term or
+// range query matches any one value of a multi-valued field rather than the 
whole array. A docvalue scan used to
+// push the comparison as a term query on the constant's text, such as 
{"term":{"c_keyword":"[a, b, c]"}}, and to
+// drop it from what Doris evaluated, so an equality matched no document and 
an inequality matched every one.
+suite("test_es_array_literal_predicate", "p2,external") {
+    String enabled = context.config.otherConfigs.get("enableEsTest")
+    if (enabled != null && enabled.equalsIgnoreCase("true")) {
+        String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
+        String es_7_port = context.config.otherConfigs.get("es_7_port")
+        String es_8_port = context.config.otherConfigs.get("es_8_port")
+
+        sql """drop catalog if exists test_es_array_literal_predicate_es7"""
+        sql """create catalog test_es_array_literal_predicate_es7 properties (
+            "type" = "es",
+            "hosts" = "http://${externalEnvIp}:${es_7_port}";,
+            "nodes_discovery" = "false",
+            "enable_keyword_sniff" = "true"
+        )"""
+        sql """drop catalog if exists test_es_array_literal_predicate_es8"""
+        sql """create catalog test_es_array_literal_predicate_es8 properties (
+            "type" = "es",
+            "hosts" = "http://${externalEnvIp}:${es_8_port}";,
+            "nodes_discovery" = "false",
+            "enable_keyword_sniff" = "true"
+        )"""
+
+        // Every document of test1 has c_keyword ["a", "b", "c"] and c_long 
[-1, 0, 1, 2]. The scan reads only
+        // docvalue fields (test3 and the filtered column), so it is a 
docvalue scan, the one that pushed these.
+        sql """switch test_es_array_literal_predicate_es7"""
+        order_qt_es7_keyword_eq """select test3 from test1 where c_keyword = 
['a', 'b', 'c']"""
+        order_qt_es7_keyword_ne """select test3 from test1 where c_keyword != 
['a', 'b', 'c']"""
+        // On a long field the text failed the whole query: failed to create 
query: For input string.
+        order_qt_es7_long_eq """select test3 from test1 where c_long = [-1, 0, 
1, 2]"""
+        order_qt_es7_and """select test3 from test1 where c_keyword = ['a', 
'b', 'c'] and test3 > 4"""
+        // The comparison is left for Doris, so the scan does not stop early 
at the LIMIT.
+        explain {
+            sql """select test3 from test1 where c_keyword = ['a', 'b', 'c'] 
limit 3"""
+            contains "PREDICATES: (c_keyword"
+            notContains "ES terminate_after"
+        }
+
+        sql """switch test_es_array_literal_predicate_es8"""
+        order_qt_es8_keyword_eq """select test3 from test1 where c_keyword = 
['a', 'b', 'c']"""
+        order_qt_es8_keyword_ne """select test3 from test1 where c_keyword != 
['a', 'b', 'c']"""
+        order_qt_es8_long_eq """select test3 from test1 where c_long = [-1, 0, 
1, 2]"""
+        order_qt_es8_and """select test3 from test1 where c_keyword = ['a', 
'b', 'c'] and test3 > 4"""
+        explain {
+            sql """select test3 from test1 where c_keyword = ['a', 'b', 'c'] 
limit 3"""
+            contains "PREDICATES: (c_keyword"
+            notContains "ES terminate_after"
+        }
+        sql """switch internal"""
+    }
+}


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

Reply via email to