diff --git a/tests/queries/0_stateless/01259_combinator_distinct.reference b/tests/queries/0_stateless/01259_combinator_distinct.reference index 94e4f7d0d17..3196d78ee44 100644 --- a/tests/queries/0_stateless/01259_combinator_distinct.reference +++ b/tests/queries/0_stateless/01259_combinator_distinct.reference @@ -10,6 +10,8 @@ 24 27 2 -SELECT uniqExactIf(number % 10, (number % 5) = 2)\nFROM numbers(10000) +SELECT uniqExactIf(number % 10, (number % 5) = 2) +FROM numbers(10000) 9 -SELECT sumDistinctIf(number % 10, (number % 5) = 2)\nFROM numbers(10000) +SELECT sumDistinctIf(number % 10, (number % 5) = 2) +FROM numbers(10000) diff --git a/tests/queries/0_stateless/01271_optimize_arithmetic_operations_in_aggr_func.reference b/tests/queries/0_stateless/01271_optimize_arithmetic_operations_in_aggr_func.reference index ba265f2a7ce..eeba2646046 100644 --- a/tests/queries/0_stateless/01271_optimize_arithmetic_operations_in_aggr_func.reference +++ b/tests/queries/0_stateless/01271_optimize_arithmetic_operations_in_aggr_func.reference @@ -1,51 +1,459 @@ -SELECT \n sum(n + 1),\n sum(1 + n),\n sum(n - 1),\n sum(1 - n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n sum(n) * 2,\n 2 * sum(n),\n sum(n) / 2,\n sum(1 / n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n min(n) + 1,\n 1 + min(n),\n min(n) - 1,\n 1 - min(n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n min(n) * 2,\n 2 * min(n),\n min(n) / 2,\n min(1 / n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n max(n) + 1,\n 1 + max(n),\n max(n) - 1,\n 1 - max(n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n max(n) * 2,\n 2 * max(n),\n max(n) / 2,\n max(1 / n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n sum(n + -1),\n sum(-1 + n),\n sum(n - -1),\n sum(-1 - n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n sum(n) * -2,\n -2 * sum(n),\n sum(n) / -2,\n sum(-1 / n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n min(n) + -1,\n -1 + min(n),\n min(n) - -1,\n -1 - min(n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n max(n) * -2,\n -2 * max(n),\n max(n) / -2,\n min(-1 / n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n max(n) + -1,\n -1 + max(n),\n max(n) - -1,\n -1 - max(n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n min(n) * -2,\n -2 * min(n),\n min(n) / -2,\n max(-1 / n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n sum(abs(2) + 1),\n sum(abs(2) + n),\n sum(n - abs(2)),\n sum(1 - abs(2))\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n sum(abs(2)) * 2,\n sum(abs(2) * n),\n sum(n / abs(2)),\n sum(1 / abs(2))\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n min(abs(2)) + 1,\n min(abs(2) + n),\n min(n - abs(2)),\n 1 - min(abs(2))\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n min(abs(2)) * 2,\n min(abs(2) * n),\n min(n / abs(2)),\n min(1 / abs(2))\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n max(abs(2)) + 1,\n max(abs(2) + n),\n max(n - abs(2)),\n 1 - max(abs(2))\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n max(abs(2)) * 2,\n max(abs(2) * n),\n max(n / abs(2)),\n max(1 / abs(2))\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n sum(abs(n) + 1),\n sum(abs(n) + n),\n sum(n - abs(n)),\n sum(1 - abs(n))\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n sum(abs(n)) * 2,\n sum(abs(n) * n),\n sum(n / abs(n)),\n sum(1 / abs(n))\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n min(abs(n)) + 1,\n min(abs(n) + n),\n min(n - abs(n)),\n 1 - min(abs(n))\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n min(abs(n)) * 2,\n min(abs(n) * n),\n min(n / abs(n)),\n min(1 / abs(n))\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n max(abs(n)) + 1,\n max(abs(n) + n),\n max(n - abs(n)),\n 1 - max(abs(n))\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n max(abs(n)) * 2,\n max(abs(n) * n),\n max(n / abs(n)),\n max(1 / abs(n))\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n sum((n * n) + 1),\n sum(1 + (n * n)),\n sum((n * n) - 1),\n sum(1 - (n * n))\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n sum(n * n) * 2,\n sum((2 * n) * n),\n sum(n * n) / 2,\n sum((1 / n) * n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n min(n * n) + 1,\n 1 + min(n * n),\n min(n * n) - 1,\n 1 - min(n * n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n min(n * n) * 2,\n min((2 * n) * n),\n min(n * n) / 2,\n min((1 / n) * n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n max(n * n) + 1,\n 1 + max(n * n),\n max(n * n) - 1,\n 1 - max(n * n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n max(n * n) * 2,\n max((2 * n) * n),\n max(n * n) / 2,\n max((1 / n) * n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n sum((1 + n) + 1),\n sum((1 + 1) + n),\n sum((1 + n) - 1),\n sum((1 + 1) - n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n sum(1 + (n * 2)),\n sum(1 + (2 * n)),\n sum(1 + (n / 2)),\n sum(1 + (1 / n))\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n (1 + min(n)) + 1,\n min((1 + 1) + n),\n (1 + min(n)) - 1,\n min((1 + 1) - n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n 1 + min(n * 2),\n 1 + min(2 * n),\n 1 + min(n / 2),\n 1 + min(1 / n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n (1 + max(n)) + 1,\n max((1 + 1) + n),\n (1 + max(n)) - 1,\n max((1 + 1) - n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n 1 + max(n * 2),\n 1 + max(2 * n),\n 1 + max(n / 2),\n 1 + max(1 / n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n sum((n + -1) + -1),\n sum((-1 + n) + -1),\n sum((n - -1) + -1),\n sum((-1 - n) + -1)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n (sum(n) * -2) * -1,\n (-2 * sum(n)) * -1,\n (sum(n) / -2) / -1,\n sum(-1 / n) / -1\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n (min(n) + -1) + -1,\n (-1 + min(n)) + -1,\n (min(n) - -1) + -1,\n (-1 - min(n)) + -1\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n (min(n) * -2) * -1,\n (-2 * min(n)) * -1,\n (min(n) / -2) / -1,\n max(-1 / n) / -1\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n (max(n) + -1) + -1,\n (-1 + max(n)) + -1,\n (max(n) - -1) + -1,\n (-1 - max(n)) + -1\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT \n (max(n) * -2) * -1,\n (-2 * max(n)) * -1,\n (max(n) / -2) / -1,\n min(-1 / n) / -1\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT ((sum(n + 1) + sum(1 + n)) + sum(n - 1)) + sum(1 - n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT (((sum(n) * 2) + (2 * sum(n))) + (sum(n) / 2)) + sum(1 / n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT (((min(n) + 1) + (1 + min(n))) + (min(n) - 1)) + (1 - min(n))\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT (((min(n) * 2) + (2 * min(n))) + (min(n) / 2)) + min(1 / n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT (((max(n) + 1) + (1 + max(n))) + (max(n) - 1)) + (1 - max(n))\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) -SELECT (((max(n) * 2) + (2 * max(n))) + (max(n) / 2)) + max(1 / n)\nFROM \n(\n SELECT number AS n\n FROM numbers(10)\n) +SELECT + sum(n + 1), + sum(1 + n), + sum(n - 1), + sum(1 - n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + sum(n) * 2, + 2 * sum(n), + sum(n) / 2, + sum(1 / n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + min(n) + 1, + 1 + min(n), + min(n) - 1, + 1 - min(n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + min(n) * 2, + 2 * min(n), + min(n) / 2, + min(1 / n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + max(n) + 1, + 1 + max(n), + max(n) - 1, + 1 - max(n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + max(n) * 2, + 2 * max(n), + max(n) / 2, + max(1 / n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + sum(n + -1), + sum(-1 + n), + sum(n - -1), + sum(-1 - n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + sum(n) * -2, + -2 * sum(n), + sum(n) / -2, + sum(-1 / n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + min(n) + -1, + -1 + min(n), + min(n) - -1, + -1 - min(n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + max(n) * -2, + -2 * max(n), + max(n) / -2, + min(-1 / n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + max(n) + -1, + -1 + max(n), + max(n) - -1, + -1 - max(n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + min(n) * -2, + -2 * min(n), + min(n) / -2, + max(-1 / n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + sum(abs(2) + 1), + sum(abs(2) + n), + sum(n - abs(2)), + sum(1 - abs(2)) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + sum(abs(2)) * 2, + sum(abs(2) * n), + sum(n / abs(2)), + sum(1 / abs(2)) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + min(abs(2)) + 1, + min(abs(2) + n), + min(n - abs(2)), + 1 - min(abs(2)) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + min(abs(2)) * 2, + min(abs(2) * n), + min(n / abs(2)), + min(1 / abs(2)) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + max(abs(2)) + 1, + max(abs(2) + n), + max(n - abs(2)), + 1 - max(abs(2)) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + max(abs(2)) * 2, + max(abs(2) * n), + max(n / abs(2)), + max(1 / abs(2)) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + sum(abs(n) + 1), + sum(abs(n) + n), + sum(n - abs(n)), + sum(1 - abs(n)) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + sum(abs(n)) * 2, + sum(abs(n) * n), + sum(n / abs(n)), + sum(1 / abs(n)) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + min(abs(n)) + 1, + min(abs(n) + n), + min(n - abs(n)), + 1 - min(abs(n)) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + min(abs(n)) * 2, + min(abs(n) * n), + min(n / abs(n)), + min(1 / abs(n)) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + max(abs(n)) + 1, + max(abs(n) + n), + max(n - abs(n)), + 1 - max(abs(n)) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + max(abs(n)) * 2, + max(abs(n) * n), + max(n / abs(n)), + max(1 / abs(n)) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + sum((n * n) + 1), + sum(1 + (n * n)), + sum((n * n) - 1), + sum(1 - (n * n)) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + sum(n * n) * 2, + sum((2 * n) * n), + sum(n * n) / 2, + sum((1 / n) * n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + min(n * n) + 1, + 1 + min(n * n), + min(n * n) - 1, + 1 - min(n * n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + min(n * n) * 2, + min((2 * n) * n), + min(n * n) / 2, + min((1 / n) * n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + max(n * n) + 1, + 1 + max(n * n), + max(n * n) - 1, + 1 - max(n * n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + max(n * n) * 2, + max((2 * n) * n), + max(n * n) / 2, + max((1 / n) * n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + sum((1 + n) + 1), + sum((1 + 1) + n), + sum((1 + n) - 1), + sum((1 + 1) - n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + sum(1 + (n * 2)), + sum(1 + (2 * n)), + sum(1 + (n / 2)), + sum(1 + (1 / n)) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + (1 + min(n)) + 1, + min((1 + 1) + n), + (1 + min(n)) - 1, + min((1 + 1) - n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + 1 + min(n * 2), + 1 + min(2 * n), + 1 + min(n / 2), + 1 + min(1 / n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + (1 + max(n)) + 1, + max((1 + 1) + n), + (1 + max(n)) - 1, + max((1 + 1) - n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + 1 + max(n * 2), + 1 + max(2 * n), + 1 + max(n / 2), + 1 + max(1 / n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + sum((n + -1) + -1), + sum((-1 + n) + -1), + sum((n - -1) + -1), + sum((-1 - n) + -1) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + (sum(n) * -2) * -1, + (-2 * sum(n)) * -1, + (sum(n) / -2) / -1, + sum(-1 / n) / -1 +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + (min(n) + -1) + -1, + (-1 + min(n)) + -1, + (min(n) - -1) + -1, + (-1 - min(n)) + -1 +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + (min(n) * -2) * -1, + (-2 * min(n)) * -1, + (min(n) / -2) / -1, + max(-1 / n) / -1 +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + (max(n) + -1) + -1, + (-1 + max(n)) + -1, + (max(n) - -1) + -1, + (-1 - max(n)) + -1 +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT + (max(n) * -2) * -1, + (-2 * max(n)) * -1, + (max(n) / -2) / -1, + min(-1 / n) / -1 +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT ((sum(n + 1) + sum(1 + n)) + sum(n - 1)) + sum(1 - n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT (((sum(n) * 2) + (2 * sum(n))) + (sum(n) / 2)) + sum(1 / n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT (((min(n) + 1) + (1 + min(n))) + (min(n) - 1)) + (1 - min(n)) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT (((min(n) * 2) + (2 * min(n))) + (min(n) / 2)) + min(1 / n) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT (((max(n) + 1) + (1 + max(n))) + (max(n) - 1)) + (1 - max(n)) +FROM +( + SELECT number AS n + FROM numbers(10) +) +SELECT (((max(n) * 2) + (2 * max(n))) + (max(n) / 2)) + max(1 / n) +FROM +( + SELECT number AS n + FROM numbers(10) +) 55 55 35 -35 90 90 22.5 inf 1 1 -1 1