blob: 091cdaa67a041c443853c13e6b918bb6966af625 [file] [log] [blame]
/*
* 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 }
CREATE OR REPLACE AGGREGATE FUNCTION ${self()}(key STRING, value INT64)
RETURNS BYTES
OPTIONS (
description = '''Creates a sketch that represents the cardinality of the given STRING column
with an additional INT64 value associated with each key.
Multiple values for the same key are aggregated using one of the selectable
operations: SUM, MIN, MAX.
Param key: the STRING column of identifiers.
Param value: the INT64 value associated with the key.
Returns: a Compact Tuple Sketch, as bytes, which can be queried for results
or used in other sketch operations.
For more details: https://datasketches.apache.org/docs/Tuple/TupleOverview.html'''
) AS (
$BQ_DATASET.tuple_sketch_int64_agg_string_lgk_seed_p_mode(key, value, STRUCT<BYTEINT, INT64, FLOAT64, STRING>(NULL, NULL, NULL, NULL))
);