davecromberge commented on code in PR #7: URL: https://github.com/apache/datasketches-bigquery/pull/7#discussion_r1717341464
########## kll_sketch_float_to_tring.sqlx: ########## @@ -0,0 +1,38 @@ +# 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. + +CREATE OR REPLACE FUNCTION `$BQ_PROJECT.$BQ_DATASET`.kll_sketch_float_to_string(base64 BYTES) Review Comment: The filename should probably match the function name. ########## kll_sketch_float_get_quantile.sqlx: ########## @@ -0,0 +1,41 @@ +# 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. + +CREATE OR REPLACE FUNCTION `$BQ_PROJECT.$BQ_DATASET`.kll_sketch_float_get_quantile(sketch BYTES, rank FLOAT64, inclusive BOOL) +RETURNS FLOAT64 +LANGUAGE js +OPTIONS ( + library=["gs://$GCS_BUCKET/kll_sketch.js"], + description = '''Returns a value from the sketch that is the best approximation to a value from the original stream with the given rank. +Param sketch: the given sketch in serialized form. +Param rank: rank of a value in the hypothetical sorted stream. +Param inclusive: if true, the given rank is considered inclusive (includes weight of a value) +Returns an approximate quantile associated with the given rank. +For more details: https://datasketches.apache.org/docs/KLL/KLLSketch.html''' +) AS R""" +try { + var sketch = Module.kll_sketch_float.deserializeFromB64(sketch); + try { + if (sketch.isEmpty()) return null; + return sketch.getRank(rank, inclusive); Review Comment: The `...get_rank` function uses `sketch.getQuantile` and this function uses `getRank` - is this in error? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
