| /* |
| * 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. |
| */ |
| |
| config { hasOutput: true, tags: ["tuple", "udfs"] } |
| |
| CREATE OR REPLACE AGGREGATE FUNCTION ${self()}(key STRING, value INT64) |
| RETURNS BYTES |
| OPTIONS ( |
| description = '''Builds a Tuple Sketch from a STRING Key column and an INT64 value column. |
| Multiple values for the same key are aggregated using the default mode. |
| Note that cardinality estimation accuracy, plots, error tables, and sampling probability p are the same as the Theta Sketch. |
| This function only applies to Tuple Sketches with a STRING Key column and an INT64 summary column. |
| |
| Param key: the STRING column of identifiers. This may not be NULL. |
| Param value: the INT64 value column associated with each key. This may not be NULL. |
| Defaults: lg_k = 12, seed = 9001, p = 1.0, mode = SUM. |
| Returns: a Compact Tuple Sketch as BYTES. |
| |
| For more information: |
| - https://datasketches.apache.org/docs/Tuple/TupleSketches.html |
| ''' |
| ) AS ( |
| ${ref("tuple_sketch_int64_agg_string_lgk_seed_p_mode")}(key, value, STRUCT<BYTEINT, INT64, FLOAT64, STRING>(NULL, NULL, NULL, NULL)) |
| ); |