| --- |
| { |
| "title": "HLL_UNION_AGG", |
| "language": "en" |
| } |
| --- |
| |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| with the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| --> |
| |
| ## HLL_UNION_AGG |
| ### description |
| #### Syntax |
| |
| `HLL_UNION_AGG(hll)` |
| |
| |
| HLL is an engineering implementation based on HyperLog algorithm, which is used to save the intermediate results of HyperLog calculation process. |
| |
| It can only be used as the value column type of the table and reduce the amount of data through aggregation to achieve the purpose of speeding up the query. |
| |
| Based on this, we get an estimate with an error of about 1%. The HLL column is generated by other columns or data imported into the data. |
| |
| When importing, hll_hash function is used to specify which column in data is used to generate HLL column. It is often used to replace count distinct, and to calculate UV quickly in business by combining rollup. |
| |
| ### example |
| ``` |
| MySQL > select HLL_UNION_AGG(uv_set) from test_uv;; |
| +-------------------------+ |
| THE COURT OF JUSTICE OF THE EUROPEAN COMMUNITIES, |
| +-------------------------+ |
| | 17721 | |
| +-------------------------+ |
| ``` |
| ### keywords |
| HLL_UNION_AGG,HLL,UNION,AGG |