update 02861_join_on_nullsafe_compare

This commit is contained in:
vdimir 2023-09-01 12:38:07 +00:00
parent 5b5c8db7ed
commit cd2e2cab83
No known key found for this signature in database
GPG Key ID: 6EE4CE2BEDC51862
3 changed files with 47 additions and 8 deletions

View File

@ -66,4 +66,3 @@
01940_custom_tld_sharding_key
02815_range_dict_no_direct_join
02845_threads_count_in_distributed_queries
02861_join_on_nullsafe_compare

View File

@ -647,6 +647,37 @@ join_algorithm = default, join_use_nulls = 0, t1 JOIN t4
19 19 19 19
\N 20 \N 0
--
\N 0 2 2
\N 0 \N 4
\N 0 6 6
\N 0 \N 8
\N 0 10 10
\N 0 \N 12
\N 0 14 14
\N 0 \N 16
\N 0 18 18
\N 0 \N 20
1 1 1 1
\N 2 \N 0
3 3 3 3
\N 4 \N 0
5 5 5 5
\N 6 \N 0
7 7 7 7
\N 8 \N 0
9 9 9 9
\N 10 \N 0
11 11 11 11
\N 12 \N 0
13 13 13 13
\N 14 \N 0
15 15 15 15
\N 16 \N 0
17 17 17 17
\N 18 \N 0
19 19 19 19
\N 20 \N 0
--
1 42 420 1 1 43 430 1
\N 42 420 2 \N 43 430 4
\N 42 420 2 \N 43 430 8

View File

@ -30,28 +30,28 @@ SELECT 'join_algorithm = {{ join_algorithm }}, join_use_nulls = {{ join_use_null
SELECT '--';
SELECT {{ t1 }}.a, {{ t1 }}.val, {{ t2 }}.a, {{ t2 }}.val FROM {{ t1 }} FULL JOIN {{ t2 }}
ON isNotDistinctFrom({{ t1 }}.a, {{ t2 }}.a)
ON {{ t1 }}.a <=> {{ t2 }}.a
ORDER BY {{ t1 }}.val NULLS FIRST, {{ t2 }}.val NULLS FIRST
;
SELECT '--';
SELECT * FROM {{ t1 }} FULL JOIN {{ t2 }}
ON isNotDistinctFrom({{ t1 }}.a, {{ t2 }}.a) AND isNotDistinctFrom({{ t1 }}.b, {{ t2 }}.b)
ON {{ t1 }}.a <=> {{ t2 }}.a AND {{ t1 }}.b <=> {{ t2 }}.b
ORDER BY {{ t1 }}.val NULLS FIRST, {{ t2 }}.val NULLS FIRST
;
SELECT '--';
SELECT * FROM {{ t1 }} FULL JOIN {{ t2 }}
ON {{ t1 }}.a == {{ t2 }}.a AND isNotDistinctFrom({{ t1 }}.b, {{ t2 }}.b)
ON {{ t1 }}.a == {{ t2 }}.a AND {{ t1 }}.b <=> {{ t2 }}.b
ORDER BY {{ t1 }}.val NULLS FIRST, {{ t2 }}.val NULLS FIRST
;
SELECT '--';
SELECT * FROM {{ t1 }} FULL JOIN {{ t2 }}
ON isNotDistinctFrom({{ t1 }}.a, {{ t2 }}.a) AND {{ t1 }}.b == {{ t2 }}.b
ON {{ t1 }}.a <=> {{ t2 }}.a AND {{ t1 }}.b == {{ t2 }}.b
ORDER BY {{ t1 }}.val NULLS FIRST, {{ t2 }}.val NULLS FIRST
;
@ -62,7 +62,14 @@ SELECT '--';
SET join_use_nulls = 0;
SET join_algorithm = 'hash';
SELECT t1.a, t1.val, t2.a, t2.val FROM t1 FULL JOIN t2
ON isNotDistinctFrom(t1.a, t2.a) AND t1.b < 2 OR t1.a == t2.a
ON t1.a <=> t2.a AND t1.b < 2 OR t1.a == t2.a
ORDER BY t1.val NULLS FIRST, t2.val NULLS FIRST
;
SELECT '--';
SELECT t1.a, t1.val, t2.a, t2.val FROM t1 FULL JOIN t2
ON t1.a IS NOT DISTINCT FROM t2.a AND t1.b < 2 OR t1.a == t2.a
ORDER BY t1.val NULLS FIRST, t2.val NULLS FIRST
;
@ -76,7 +83,7 @@ SET join_use_nulls = 1;
SELECT *
FROM (SELECT a, 42 as `__wrapNullsafe(a)`, 420 as `tuple(a)`, val FROM t1) t1
JOIN (SELECT a, 43 as `__wrapNullsafe(t2.a)`, 430 as `tuple(t2.a)`, val FROM t2) t2
ON isNotDistinctFrom(t1.a, t2.a)
ON t1.a <=> t2.a
ORDER BY t1.val NULLS FIRST, t2.val NULLS FIRST
LIMIT 10;
@ -85,7 +92,7 @@ SELECT '--';
SELECT a, 42 as `__wrapNullsafe(a)`, 420 as `tuple(a)`, val, t2.a, 43 as `__wrapNullsafe(t2.a)`, 430 as `tuple(t2.a)`, t2.val
FROM (SELECT a, val, 111 as `__wrapNullsafe(a)_0` FROM t1) t1
JOIN (SELECT a, val, 111 as `__wrapNullsafe(t2.a)_0` FROM t2) t2
ON isNotDistinctFrom(t1.a, t2.a)
ON t1.a <=> t2.a
ORDER BY t1.val NULLS FIRST, t2.val NULLS FIRST
LIMIT 10;
@ -99,3 +106,5 @@ SELECT * FROM t1 JOIN t2 ON isNotDistinctFrom(t1.a, t2.a, t2.b); -- { serverErro
SELECT isNotDistinctFrom(a) from t1; -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
SELECT isNotDistinctFrom(a, b) from t1; -- { serverError NOT_IMPLEMENTED }
SELECT a <=> b from t1; -- { serverError NOT_IMPLEMENTED }
SELECT a IS NOT DISTINCT FROM b from t1; -- { serverError NOT_IMPLEMENTED }