ClickHouse/tests/queries/0_stateless/02011_tuple_vector_functions.sql

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

113 lines
4.6 KiB
MySQL
Raw Normal View History

SELECT tupleHammingDistance(tuple(1), tuple(1));
2021-08-27 17:05:33 +00:00
SELECT tupleHammingDistance((1, 3), (1, 2));
2021-09-09 15:19:31 +00:00
SELECT (1, 2) + tupleMultiply((3, 4), materialize((5, 1))) - (6, 3);
2021-08-27 17:05:33 +00:00
SELECT vectorDifference(tuplePlus((1, 2), (3, 4)), (5, 6));
2021-09-09 15:19:31 +00:00
SELECT tupleMinus(materialize(vectorSum(tupleMultiply(materialize((1, 2)), (3, 4)), (5, 6))), (31, 41));
2021-08-27 17:05:33 +00:00
SELECT tupleDivide((5, 8, 11), (-2, 2, 4));
SELECT tuple(1) + tuple(2);
2021-08-23 13:41:20 +00:00
2021-08-27 17:05:33 +00:00
SELECT tupleNegate((1, 0, 3.5));
2021-09-09 15:19:31 +00:00
SELECT -materialize((1, 2, 3));
2021-08-30 17:13:41 +00:00
SELECT -tuple(1);
2021-08-25 14:02:04 +00:00
2021-08-27 17:05:33 +00:00
SELECT tupleMultiplyByNumber((1, 2, 3), 0.5);
2021-09-09 15:19:31 +00:00
SELECT tupleDivideByNumber((1, 2.5, 3), materialize(0.5));
2021-08-27 15:44:04 +00:00
SELECT tupleMultiplyByNumber(tuple(1), 1);
2021-09-09 15:19:31 +00:00
SELECT tupleDivideByNumber(tuple(1), materialize(1));
2021-08-27 15:44:04 +00:00
2021-09-09 15:19:31 +00:00
SELECT materialize((1, 2.0, 3.1)) * 3;
2021-08-30 16:10:27 +00:00
SELECT 5.5 * (2, 4);
SELECT (1, 2) / 2;
SELECT 2 / (1, 1); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
2021-08-30 16:10:27 +00:00
2021-08-27 17:05:33 +00:00
SELECT tuple(1, 2, 3) * tuple(2, 3, 4);
2021-09-09 15:19:31 +00:00
SELECT dotProduct(materialize((-1, 2, 3.002)), materialize((2, 3.4, 4)));
2021-08-27 17:05:33 +00:00
SELECT scalarProduct(tuple(1), tuple(0));
2021-08-25 14:56:31 +00:00
2021-08-27 17:05:33 +00:00
SELECT L1Norm((-1, 2, -3));
SELECT L1Norm((-1, 2.5, -3.6));
2021-08-30 12:52:00 +00:00
SELECT L2Norm((1, 1.0));
2022-06-28 19:27:53 +00:00
SELECT L2SquaredNorm((1, 1.0));
2021-09-09 15:19:31 +00:00
SELECT L2Norm(materialize((-12, 5)));
2022-06-28 19:27:53 +00:00
SELECT L2SquaredNorm(materialize((-12, 5)));
2021-08-26 12:34:46 +00:00
2021-09-09 15:19:31 +00:00
SELECT max2(materialize(1), 1.5);
2021-08-26 12:34:46 +00:00
SELECT min2(-1, -3);
2021-08-27 17:05:33 +00:00
SELECT LinfNorm((1, -2.3, 1.7));
2021-08-26 18:17:44 +00:00
2021-09-16 12:43:10 +00:00
SELECT LpNorm(tuple(-1), 3.3);
2021-08-26 18:17:44 +00:00
SELECT LpNorm(tuple(-1), 3);
SELECT LpNorm(tuple(-1.1), 3);
2021-08-27 17:05:33 +00:00
SELECT LpNorm((95800, 217519, 414560), 4);
SELECT LpNorm((13, -84.4, 91, 63.1), 2) = L2Norm(tuple(13, -84.4, 91, 63.1));
2021-09-09 15:19:31 +00:00
SELECT LpNorm(materialize((13, -84.4, 91, 63.1)), 1) = L1Norm(tuple(13, -84.4, 91, 63.1));
2021-09-16 12:43:10 +00:00
SELECT LpNorm((-1, -2), 11.);
2021-08-27 17:05:33 +00:00
SELECT L1Distance((1, 2, 3), (2, 3, 1));
2021-09-09 15:19:31 +00:00
SELECT L2Distance(materialize((1, 1)), (3, -1));
2022-06-28 19:27:53 +00:00
SELECT L2SquaredDistance(materialize((1, 1)), (3, -1));
2021-08-27 17:05:33 +00:00
SELECT LinfDistance((1, 1), (1, 2));
SELECT L2Distance((5, 5), (5, 5));
2022-06-28 19:27:53 +00:00
SELECT L2SquaredDistance((5, 5), (5, 5));
2021-09-16 12:43:10 +00:00
SELECT LpDistance((1800, 1900), (18, 59), 12) - LpDistance(tuple(-22), tuple(1900), 12.);
2021-08-30 12:52:00 +00:00
2021-09-09 15:19:31 +00:00
SELECT L1Normalize(materialize((1, -4)));
2021-08-30 12:52:00 +00:00
SELECT L2Normalize((3, 4));
SELECT LinfNormalize((5, -5, 5.0));
2021-09-16 12:43:10 +00:00
SELECT LpNormalize((1, pow(31, 1 / 5)), 5.);
2021-08-30 14:31:37 +00:00
2021-09-09 15:19:31 +00:00
SELECT cosineDistance(materialize((1, 1)), (2, 2));
SELECT cosineDistance((1, 1), materialize((-3, 3.0)));
2021-08-30 14:31:37 +00:00
SELECT cosineDistance((1, 1), (-1, -1));
SELECT cosineDistance((1, 0), (0.5, sqrt(3) / 2));
SELECT (NULL, 1) + (1, NULL);
2021-09-09 15:19:31 +00:00
SELECT (NULL, 1) * materialize((1, NULL));
SELECT L2Norm((NULL, 3, 4));
2022-06-28 19:27:53 +00:00
SELECT L2SquaredNorm((NULL, 3, 4));
SELECT 2 * (1, 2, NULL);
SELECT (1, 1.0, NULL) / NULL;
2021-09-09 15:19:31 +00:00
SELECT (1, 1.0, NULL) / materialize(NULL);
SELECT -(NULL, NULL, 1);
SELECT (NULL, NULL) * NULL;
SELECT L1Normalize((NULL, 1));
SELECT cosineDistance((NULL, 1), (NULL, NULL));
SELECT max2(NULL, 1) - min2(NULL, 1);
SELECT L1Norm(1); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
SELECT (1, 1) / toString(1); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
SELECT -(1, toString(1)); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
2024-05-31 09:19:06 +00:00
SELECT LpNorm((1, 2), toDecimal32(2, 4)); -- { serverError ILLEGAL_COLUMN }
SELECT (1, 2) * toDecimal32(3.1, 8);
SELECT cosineDistance((1, 2), (2, 3, 4)); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
2023-09-27 13:28:26 +00:00
-- TODO: what's the expected value of () + ()? Currently it returns 0.
-- SELECT tuple() + tuple(); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
SELECT LpNorm((1, 2, 3)); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
SELECT max2(1, 2, -1); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
2021-09-09 15:19:31 +00:00
SELECT LpNorm((1, 2, 3), materialize(4.)); -- { serverError ILLEGAL_COLUMN }
2021-09-16 12:43:10 +00:00
2021-09-09 15:19:31 +00:00
SELECT tuple(*, 1) + tuple(2, *) FROM numbers(3);
SELECT LpDistance(tuple(*, 1), tuple(2, *), * + 1.) FROM numbers(3, 2); -- { serverError ILLEGAL_COLUMN }
2021-09-09 15:19:31 +00:00
SELECT cosineDistance(tuple(*, * + 1), tuple(1, 2)) FROM numbers(1, 3);
SELECT -tuple(NULL, * * 2, *) FROM numbers(2);
2021-09-09 15:45:05 +00:00
2021-09-16 12:43:10 +00:00
SELECT normL1((1, 1)), normL2((1, 1)), normLinf((1, 1)), normLp((1, 1), 1.);
SELECT distanceL1((1, 1), (1, 1)), distanceL2((1, 1), (1, 1)), distanceLinf((1, 1), (1, 1)), distanceLp((1, 1), (1, 1), 1.);
SELECT normalizeL1((1, 1)), normalizeL2((1, 1)), normalizeLinf((1, 1)), normalizeLp((1, 1), 1.);
SELECT LpNorm((1, 2, 3), 2.2);
SELECT LpNorm((1.5, 2.5, 4), pi());
SELECT LpNorm((3, 1, 4), 0); -- { serverError ARGUMENT_OUT_OF_BOUND }
SELECT LpNorm((1, 2, 3), 0.5); -- { serverError ARGUMENT_OUT_OF_BOUND }
SELECT LpNorm((1, 2, 3), inf); -- { serverError ARGUMENT_OUT_OF_BOUND }
SELECT LpNorm((1, 2, 3), -1.); -- { serverError ARGUMENT_OUT_OF_BOUND }
SELECT LpNorm((1, 2, 3), -1); -- { serverError ILLEGAL_COLUMN }
SELECT LpNorm((1, 2, 3), 0.); -- { serverError ARGUMENT_OUT_OF_BOUND }
2021-09-23 12:54:00 +00:00
SELECT cosineDistance(materialize((NULL, -2147483648)), (1048577, 1048575));
-- not extra parentheses
EXPLAIN SYNTAX SELECT -((3, 7, 3), 100);