Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ All notable changes to this project will be documented in this file. It uses the
* Fixed a memory leak in the http driver when not using streaming ([#281]).
* Fixed a memory leak when a foreign scan repeatedly re-scans, typically a
nested-loop join with a parameterized inner foreign scan ([#282]).
* Change the deparsing of `ANY()` with an empty array (`WHERE x = ANY('{}')`)
to a `has()` function rather than an `IN()` expression. This fixes errors
on versions prior to ClickHouse 25, where `IN()` with no list returns an
error ([#285])

### 🏗️ Build Setup

Expand All @@ -65,6 +69,8 @@ All notable changes to this project will be documented in this file. It uses the
[clang-format]: https://clang.llvm.org/docs/ClangFormat.html
[#283]: https://github.com/ClickHouse/pg_clickhouse/pull/283
"ClickHouse/pg_clickhouse#283 clang-format"
[#285]: https://github.com/ClickHouse/pg_clickhouse/pull/285
"ClickHouse/pg_clickhouse#285 Don't use `IN` for empty array (`ANY('{}')`)"

## [v0.3.1] — 2026-05-02

Expand Down
41 changes: 37 additions & 4 deletions src/deparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -3852,6 +3852,39 @@ deparseAsIn(ScalarArrayOpExpr* node, deparse_expr_cxt* context, int optype) {
context->array_as_tuple = false;
}

/*
* Returns true if `node` is a constant and, if it's output is an array, the
* array has more than one value. Replace with `IsA(expr, Const)` when
* ClickHouse 24 support dropped.
*/
static bool
is_ok_in_expr(Expr* expr) {
Const* node;
Oid typoutput;
bool typIsVarlena;
AnyArrayType* array;

if (!IsA(expr, Const)) {
return false;
}

node = (Const*)expr;
getTypeOutputInfo(node->consttype, &typoutput, &typIsVarlena);
if (typoutput != F_ARRAY_OUT) {
return true;
}

/*
* An empty `IN()` was invalid prior to ClickHouse 25, so disqualify an
* empty array. We could change things to `WHERE false` in this situation,
* but hopefully this workaround is temporary until we drop ClickHouse 24
* support someday, so just leave it to the ClickHouse optimizer to deal
* with it.
*/
array = DatumGetAnyArrayP((Datum)node->constvalue);
return AARR_NDIM(array) > 0;
}

/*
* Deparse given ScalarArrayOpExpr expression. To avoid problems around
* priority of operations, we always parenthesize the arguments.
Expand Down Expand Up @@ -3883,8 +3916,8 @@ deparseScalarArrayOpExpr(ScalarArrayOpExpr* node, deparse_expr_cxt* context) {
if (node->useOr) {
arg2 = lsecond(node->args);

/* very narrow case for = ANY(ARRAY) */
if (optype == 1 && IsA(arg2, Const)) {
/* very narrow case for IN() and = ANY(ARRAY) */
if (optype == 1 && is_ok_in_expr(arg2)) {
deparseAsIn(node, context, optype);
} else {
if (optype == 1) {
Expand All @@ -3907,8 +3940,8 @@ deparseScalarArrayOpExpr(ScalarArrayOpExpr* node, deparse_expr_cxt* context) {
} else {
arg2 = lsecond(node->args);

/* very narrow case for <> ALL(ARRAY) */
if (optype == 2 && IsA(arg2, Const)) {
/* very narrow case for NOT IN() and <> ANY(ARRAY) */
if (optype == 2 && is_ok_in_expr(arg2)) {
deparseAsIn(node, context, optype);
} else {
appendStringInfoString(buf, "countEqual(");
Expand Down
14 changes: 14 additions & 0 deletions test/expected/binary_queries.out
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,20 @@ SELECT * FROM ft1 t1 WHERE c1 = ANY(ARRAY[c2, 1, c1 + 0]) ORDER BY c1; -- Scalar
110 | 0 | 110 | 1990-01-01 | 1990-01-01 | 0 | 0 | foo
(110 rows)

-- Syntax error on ClickHouse 24 and earlier.
EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
QUERY PLAN
------------------------------------------------------------------------------------------------------
Foreign Scan on binary_queries_test.ft1 t1
Output: c1, c2, c3, c4, c5, c6, c7, c8
Remote SQL: SELECT c1, c2, c3, c4, c5, c6, c7, c8 FROM binary_queries_test.t1 WHERE ((has([],c1)))
(3 rows)

SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8
----+----+----+----+----+----+----+----
(0 rows)

EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = (ARRAY[c1,c2,3])[1]; -- ArrayRef
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions test/expected/binary_queries_1.out
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,20 @@ SELECT * FROM ft1 t1 WHERE c1 = ANY(ARRAY[c2, 1, c1 + 0]) ORDER BY c1; -- Scalar
110 | 0 | 110 | 1990-01-01 | 1990-01-01 | 0 | 0 | foo
(110 rows)

-- Syntax error on ClickHouse 24 and earlier.
EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
QUERY PLAN
------------------------------------------------------------------------------------------------------
Foreign Scan on binary_queries_test.ft1 t1
Output: c1, c2, c3, c4, c5, c6, c7, c8
Remote SQL: SELECT c1, c2, c3, c4, c5, c6, c7, c8 FROM binary_queries_test.t1 WHERE ((has([],c1)))
(3 rows)

SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8
----+----+----+----+----+----+----+----
(0 rows)

EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = (ARRAY[c1,c2,3])[1]; -- ArrayRef
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions test/expected/binary_queries_2.out
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,20 @@ SELECT * FROM ft1 t1 WHERE c1 = ANY(ARRAY[c2, 1, c1 + 0]) ORDER BY c1; -- Scalar
110 | 0 | 110 | 1990-01-01 | 1990-01-01 | 0 | 0 | foo
(110 rows)

-- Syntax error on ClickHouse 24 and earlier.
EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
QUERY PLAN
------------------------------------------------------------------------------------------------------
Foreign Scan on binary_queries_test.ft1 t1
Output: c1, c2, c3, c4, c5, c6, c7, c8
Remote SQL: SELECT c1, c2, c3, c4, c5, c6, c7, c8 FROM binary_queries_test.t1 WHERE ((has([],c1)))
(3 rows)

SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8
----+----+----+----+----+----+----+----
(0 rows)

EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = (ARRAY[c1,c2,3])[1]; -- ArrayRef
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions test/expected/binary_queries_3.out
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,20 @@ SELECT * FROM ft1 t1 WHERE c1 = ANY(ARRAY[c2, 1, c1 + 0]) ORDER BY c1; -- Scalar
110 | 0 | 110 | 1990-01-01 | 1990-01-01 | 0 | 0 | foo
(110 rows)

-- Syntax error on ClickHouse 24 and earlier.
EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
QUERY PLAN
------------------------------------------------------------------------------------------------------
Foreign Scan on binary_queries_test.ft1 t1
Output: c1, c2, c3, c4, c5, c6, c7, c8
Remote SQL: SELECT c1, c2, c3, c4, c5, c6, c7, c8 FROM binary_queries_test.t1 WHERE ((has([],c1)))
(3 rows)

SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8
----+----+----+----+----+----+----+----
(0 rows)

EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = (ARRAY[c1,c2,3])[1]; -- ArrayRef
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions test/expected/binary_queries_4.out
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,20 @@ SELECT * FROM ft1 t1 WHERE c1 = ANY(ARRAY[c2, 1, c1 + 0]) ORDER BY c1; -- Scalar
110 | 0 | 110 | 1990-01-01 | 1990-01-01 | 0 | 0 | foo
(110 rows)

-- Syntax error on ClickHouse 24 and earlier.
EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
QUERY PLAN
------------------------------------------------------------------------------------------------------
Foreign Scan on binary_queries_test.ft1 t1
Output: c1, c2, c3, c4, c5, c6, c7, c8
Remote SQL: SELECT c1, c2, c3, c4, c5, c6, c7, c8 FROM binary_queries_test.t1 WHERE ((has([],c1)))
(3 rows)

SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8
----+----+----+----+----+----+----+----
(0 rows)

EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = (ARRAY[c1,c2,3])[1]; -- ArrayRef
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions test/expected/binary_queries_5.out
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,20 @@ SELECT * FROM ft1 t1 WHERE c1 = ANY(ARRAY[c2, 1, c1 + 0]) ORDER BY c1; -- Scalar
110 | 0 | 110 | 1990-01-01 | 1990-01-01 | 0 | 0 | foo
(110 rows)

-- Syntax error on ClickHouse 24 and earlier.
EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
QUERY PLAN
------------------------------------------------------------------------------------------------------
Foreign Scan on binary_queries_test.ft1 t1
Output: c1, c2, c3, c4, c5, c6, c7, c8
Remote SQL: SELECT c1, c2, c3, c4, c5, c6, c7, c8 FROM binary_queries_test.t1 WHERE ((has([],c1)))
(3 rows)

SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8
----+----+----+----+----+----+----+----
(0 rows)

EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = (ARRAY[c1,c2,3])[1]; -- ArrayRef
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions test/expected/binary_queries_6.out
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,20 @@ SELECT * FROM ft1 t1 WHERE c1 = ANY(ARRAY[c2, 1, c1 + 0]) ORDER BY c1; -- Scalar
110 | 0 | 110 | 1990-01-01 | 1990-01-01 | 0 | 0 | foo
(110 rows)

-- Syntax error on ClickHouse 24 and earlier.
EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
QUERY PLAN
------------------------------------------------------------------------------------------------------
Foreign Scan on binary_queries_test.ft1 t1
Output: c1, c2, c3, c4, c5, c6, c7, c8
Remote SQL: SELECT c1, c2, c3, c4, c5, c6, c7, c8 FROM binary_queries_test.t1 WHERE ((has([],c1)))
(3 rows)

SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8
----+----+----+----+----+----+----+----
(0 rows)

EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = (ARRAY[c1,c2,3])[1]; -- ArrayRef
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions test/expected/http.out
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,20 @@ SELECT * FROM ft1 t1 WHERE c1 = ANY(ARRAY[c2, 1, c1 + 0]) ORDER BY c1; -- Scalar
110 | 0 | 00110 | 1990-01-01 | 1990-01-01 | 0 | 0 | foo
(110 rows)

-- Syntax error on ClickHouse 24 and earlier.
EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
QUERY PLAN
--------------------------------------------------------------------------------------------
Foreign Scan on public.ft1 t1
Output: c1, c2, c3, c4, c5, c6, c7, c8
Remote SQL: SELECT c1, c2, c3, c4, c5, c6, c7, c8 FROM http_test.t1 WHERE ((has([],c1)))
(3 rows)

SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8
----+----+----+----+----+----+----+----
(0 rows)

EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = (ARRAY[c1,c2,3])[1]; -- ArrayRef
QUERY PLAN
---------------------------------------------------------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions test/expected/http_1.out
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,20 @@ SELECT * FROM ft1 t1 WHERE c1 = ANY(ARRAY[c2, 1, c1 + 0]) ORDER BY c1; -- Scalar
110 | 0 | 00110 | 1990-01-01 | 1990-01-01 | 0 | 0 | foo
(110 rows)

-- Syntax error on ClickHouse 24 and earlier.
EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
QUERY PLAN
--------------------------------------------------------------------------------------------
Foreign Scan on public.ft1 t1
Output: c1, c2, c3, c4, c5, c6, c7, c8
Remote SQL: SELECT c1, c2, c3, c4, c5, c6, c7, c8 FROM http_test.t1 WHERE ((has([],c1)))
(3 rows)

SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8
----+----+----+----+----+----+----+----
(0 rows)

EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = (ARRAY[c1,c2,3])[1]; -- ArrayRef
QUERY PLAN
---------------------------------------------------------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions test/expected/http_2.out
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,20 @@ SELECT * FROM ft1 t1 WHERE c1 = ANY(ARRAY[c2, 1, c1 + 0]) ORDER BY c1; -- Scalar
110 | 0 | 00110 | 1990-01-01 | 1990-01-01 | 0 | 0 | foo
(110 rows)

-- Syntax error on ClickHouse 24 and earlier.
EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
QUERY PLAN
--------------------------------------------------------------------------------------------
Foreign Scan on public.ft1 t1
Output: c1, c2, c3, c4, c5, c6, c7, c8
Remote SQL: SELECT c1, c2, c3, c4, c5, c6, c7, c8 FROM http_test.t1 WHERE ((has([],c1)))
(3 rows)

SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8
----+----+----+----+----+----+----+----
(0 rows)

EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = (ARRAY[c1,c2,3])[1]; -- ArrayRef
QUERY PLAN
---------------------------------------------------------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions test/expected/http_3.out
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,20 @@ SELECT * FROM ft1 t1 WHERE c1 = ANY(ARRAY[c2, 1, c1 + 0]) ORDER BY c1; -- Scalar
110 | 0 | 00110 | 1990-01-01 | 1990-01-01 | 0 | 0 | foo
(110 rows)

-- Syntax error on ClickHouse 24 and earlier.
EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
QUERY PLAN
--------------------------------------------------------------------------------------------
Foreign Scan on public.ft1 t1
Output: c1, c2, c3, c4, c5, c6, c7, c8
Remote SQL: SELECT c1, c2, c3, c4, c5, c6, c7, c8 FROM http_test.t1 WHERE ((has([],c1)))
(3 rows)

SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8
----+----+----+----+----+----+----+----
(0 rows)

EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = (ARRAY[c1,c2,3])[1]; -- ArrayRef
QUERY PLAN
---------------------------------------------------------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions test/expected/http_4.out
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,20 @@ SELECT * FROM ft1 t1 WHERE c1 = ANY(ARRAY[c2, 1, c1 + 0]) ORDER BY c1; -- Scalar
110 | 0 | 00110 | 1990-01-01 | 1990-01-01 | 0 | 0 | foo
(110 rows)

-- Syntax error on ClickHouse 24 and earlier.
EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
QUERY PLAN
--------------------------------------------------------------------------------------------
Foreign Scan on public.ft1 t1
Output: c1, c2, c3, c4, c5, c6, c7, c8
Remote SQL: SELECT c1, c2, c3, c4, c5, c6, c7, c8 FROM http_test.t1 WHERE ((has([],c1)))
(3 rows)

SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8
----+----+----+----+----+----+----+----
(0 rows)

EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = (ARRAY[c1,c2,3])[1]; -- ArrayRef
QUERY PLAN
---------------------------------------------------------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions test/expected/http_5.out
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,20 @@ SELECT * FROM ft1 t1 WHERE c1 = ANY(ARRAY[c2, 1, c1 + 0]) ORDER BY c1; -- Scalar
110 | 0 | 00110 | 1990-01-01 | 1990-01-01 | 0 | 0 | foo
(110 rows)

-- Syntax error on ClickHouse 24 and earlier.
EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
QUERY PLAN
--------------------------------------------------------------------------------------------
Foreign Scan on public.ft1 t1
Output: c1, c2, c3, c4, c5, c6, c7, c8
Remote SQL: SELECT c1, c2, c3, c4, c5, c6, c7, c8 FROM http_test.t1 WHERE ((has([],c1)))
(3 rows)

SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8
----+----+----+----+----+----+----+----
(0 rows)

EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = (ARRAY[c1,c2,3])[1]; -- ArrayRef
QUERY PLAN
---------------------------------------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions test/sql/binary_queries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = ANY(ARRAY[c2, 1, c1

SELECT * FROM ft1 t1 WHERE c1 = ANY(ARRAY[c2, 1, c1 + 0]) ORDER BY c1; -- ScalarArrayOpExpr

-- Syntax error on ClickHouse 24 and earlier.
EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr

EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = (ARRAY[c1,c2,3])[1]; -- ArrayRef

SELECT * FROM ft1 t1 WHERE c1 = (ARRAY[c1,c2,3])[1] ORDER BY c1; -- ArrayRef
Expand Down
4 changes: 4 additions & 0 deletions test/sql/http.sql
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = ANY(ARRAY[c2, 1, c1

SELECT * FROM ft1 t1 WHERE c1 = ANY(ARRAY[c2, 1, c1 + 0]) ORDER BY c1; -- ScalarArrayOpExpr

-- Syntax error on ClickHouse 24 and earlier.
EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr
SELECT * FROM ft1 t1 WHERE c1 = ANY('{}'); -- Empty ScalarArrayOpExpr

EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = (ARRAY[c1,c2,3])[1]; -- ArrayRef

SELECT * FROM ft1 t1 WHERE c1 = (ARRAY[c1,c2,3])[1] ORDER BY c1; -- ArrayRef
Expand Down
Loading