diff --git a/dbms/tests/queries/0_stateless/00276_sample.reference b/dbms/tests/queries/0_stateless/00276_sample.reference new file mode 100644 index 00000000000..d29c19d7a32 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00276_sample.reference @@ -0,0 +1,821 @@ +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +256 +65536 diff --git a/dbms/tests/queries/0_stateless/00276_sample.sql b/dbms/tests/queries/0_stateless/00276_sample.sql index e2d24850759..5d5e6e5838e 100644 --- a/dbms/tests/queries/0_stateless/00276_sample.sql +++ b/dbms/tests/queries/0_stateless/00276_sample.sql @@ -140,3 +140,123 @@ FROM ); DROP TABLE test.sample; + + +CREATE TABLE test.sample (d Date DEFAULT '2000-01-01', x UInt16) ENGINE = MergeTree(d, x, x, 10); +INSERT INTO test.sample (x) SELECT toUInt16(number) AS x FROM system.numbers LIMIT 65536; + +SELECT count() +FROM +( + SELECT + x, + count() AS c + FROM + ( + SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.00 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.01 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.02 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.03 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.04 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.05 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.06 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.07 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.08 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.09 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.10 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.11 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.12 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.13 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.14 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.15 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.16 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.17 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.18 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.19 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.20 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.21 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.22 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.23 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.24 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.25 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.26 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.27 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.28 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.29 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.30 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.31 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.32 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.33 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.34 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.35 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.36 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.37 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.38 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.39 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.40 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.41 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.42 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.43 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.44 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.45 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.46 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.47 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.48 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.49 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.50 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.51 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.52 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.53 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.54 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.55 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.56 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.57 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.58 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.59 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.60 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.61 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.62 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.63 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.64 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.65 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.66 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.67 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.68 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.69 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.70 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.71 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.72 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.73 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.74 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.75 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.76 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.77 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.78 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.79 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.80 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.81 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.82 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.83 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.84 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.85 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.86 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.87 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.88 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.89 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.90 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.91 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.92 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.93 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.94 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.95 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.96 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.97 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.98 + UNION ALL SELECT * FROM test.sample SAMPLE 0.01 OFFSET 0.99 + ) + GROUP BY x + HAVING c = 1 + ORDER BY x ASC +); + +DROP TABLE test.sample;