|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +# Type-based string entry points run common setup for all tests, which makes |
| 19 | +# custom per-test data or table setup harder to add. Such tests belong here. |
| 20 | + |
| 21 | +# find_in_set with an array on the left and a literal on the right |
| 22 | +query III |
| 23 | +SELECT |
| 24 | + find_in_set(arrow_cast(column1, 'Utf8'), arrow_cast('a,b,c', 'Utf8')), |
| 25 | + find_in_set(arrow_cast(column1, 'LargeUtf8'), arrow_cast('a,b,c', 'LargeUtf8')), |
| 26 | + find_in_set(arrow_cast(column1, 'Utf8View'), arrow_cast('a,b,c', 'Utf8View')) |
| 27 | +FROM (VALUES ('b'), ('x'), (NULL)) AS t(column1); |
| 28 | +---- |
| 29 | +2 2 2 |
| 30 | +0 0 0 |
| 31 | +NULL NULL NULL |
| 32 | + |
| 33 | +# find_in_set with a literal on the left and an array on the right |
| 34 | +query III |
| 35 | +SELECT |
| 36 | + find_in_set(arrow_cast('b', 'Utf8'), arrow_cast(column1, 'Utf8')), |
| 37 | + find_in_set(arrow_cast('b', 'LargeUtf8'), arrow_cast(column1, 'LargeUtf8')), |
| 38 | + find_in_set(arrow_cast('b', 'Utf8View'), arrow_cast(column1, 'Utf8View')) |
| 39 | +FROM (VALUES ('a,b,c'), ('x,y'), (NULL)) AS t(column1); |
| 40 | +---- |
| 41 | +2 2 2 |
| 42 | +0 0 0 |
| 43 | +NULL NULL NULL |
| 44 | + |
| 45 | +# find_in_set with arrays on both sides |
| 46 | +query III |
| 47 | +SELECT |
| 48 | + find_in_set(arrow_cast(column1, 'Utf8'), arrow_cast(column2, 'Utf8')), |
| 49 | + find_in_set(arrow_cast(column1, 'LargeUtf8'), arrow_cast(column2, 'LargeUtf8')), |
| 50 | + find_in_set(arrow_cast(column1, 'Utf8View'), arrow_cast(column2, 'Utf8View')) |
| 51 | +FROM (VALUES ('b', 'a,b,c'), ('x', 'x,y'), (NULL, 'a,b'), ('a', NULL)) AS t(column1, column2); |
| 52 | +---- |
| 53 | +2 2 2 |
| 54 | +1 1 1 |
| 55 | +NULL NULL NULL |
| 56 | +NULL NULL NULL |
| 57 | + |
| 58 | +# null literals paired with arrays |
| 59 | +query II |
| 60 | +SELECT |
| 61 | + find_in_set(arrow_cast(column1, 'Utf8'), arrow_cast(NULL, 'Utf8')), |
| 62 | + find_in_set(arrow_cast(NULL, 'LargeUtf8'), arrow_cast(column1, 'LargeUtf8')) |
| 63 | +FROM (VALUES ('a,b'), (NULL)) AS t(column1); |
| 64 | +---- |
| 65 | +NULL NULL |
| 66 | +NULL NULL |
| 67 | + |
| 68 | +# invalid argument count and type |
| 69 | +query error 'find_in_set' does not support zero arguments |
| 70 | +SELECT find_in_set(); |
| 71 | + |
| 72 | +query error No function matches the given name and argument types 'find_in_set\(Utf8\)' |
| 73 | +SELECT find_in_set('a'); |
| 74 | + |
| 75 | +query error No function matches the given name and argument types 'find_in_set\(Utf8, Utf8, Utf8\)' |
| 76 | +SELECT find_in_set('a', 'a,b', 'extra'); |
0 commit comments