Additional Functions for Window Functions - sql

Thank you so much for the window functions!!!
I'm curious if some more "basic" aggregates will be supported:
Sum()
Average()
Min()
Max()
Current result of trying to use Sum():
Error: Unrecognized Analytic Function: SUM cannot be used with an OVER() clause.

These are currently on the feature roadmap, but we do not have an ETA at this time. Anyone interested in these functions should vote up this question, and we'll use that to prioritize the feature request.

Related

CURRENT in BigQuery?

I've noticed that CURRENT is a reserved keyword for BigQuery at: https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical.
What exactly does CURRENT do? I've only seen it as a prefix for things such as CURRENT_TIME(), CURRENT_DATE(), and other such stuff but have never seen it by itself. Is this just reserved for future usage or do any SQL statements contain that as a keyword?
Just to add on the comment of #Jaytiger:
CURRENT keyword seems to be reserved as a part of SQL 2016 spec. en.wikipedia.org/wiki/SQL_reserved_words And you can check it's usage
in another DBMS implementations like Oracle, SQL Server. hope this is
helpful.
stackoverflow.com/questions/49110728/where-current-of-in-pl-sql
In BigQuery CURRENT clause is used on defining frame_start and frame_end in window functions.
A window function, also known as an analytic function, computes values
over a group of rows and returns a single result for each row.
A common usage for this is calculating a cumulative sum for each category in the table. See BigQuery window function examples for reference.

How to write Window functions using Druid?

For example, i wanted to write Window functions like sum over (window)
Since over clause is not supported by Druid, how do i achieve the same using Druid Native query API or SQL API?
You should use a GroupBy Query. As Druid is a time series database, you have to specify your interval (window) where you want to query data from. You can use aggregation methods over this data, for example a SUM() aggregation.
If you want, you can also do extra filtering within your aggregation, like "only sum records where city=paris"). You could also apply the SUM aggregation only to records which exists in a certain time window within your selected interval.
If you are a PHP user then maybe this package is handy for you: https://github.com/level23/druid-client#sum
We have tried to implement an easy way to query such data.

How to use WEEKNUM in big query?

I am using Big Query SQL and I can't use a couple of functions and more specifically WEEKNUM. Everytime I try to, it outputs unrecognized function.
WEEKNUM
During my search I found this that I think it meansI can't use derive functions, and I also think that part of it is the WEEKNUM. I could be totally wrong though.
So how can I use the WEEKNUM function or do what it does with another way?
Thanks
In Standard SQL, use EXTRACT():
select extract(week from current_date)
Your link to WEEKNUM is for Google Cloud DataPrep. The BigQuery Documentation for date functions does not use WEEKNUM, but allows similar functionality through EXTRACT or FORMAT_DATE.

List of aggregation functions in Spark SQL

I'm looking for a list of pre-defined aggregation functions in Spark SQL. I have in mind something analogous to Presto Aggregate Functions.
I Ctrl+F'd around a little in the SQL API docs to no avail... it's also hard to tell at a glance which functions are for aggregation vs. not. For example, if I didn't know avg is an aggregation function I'd be hard pressed to tell it is one (in a way that's actually scalable to the full set of functions):
avg - avg(expr) - Returns the mean calculated from values of a group.
If such a list doesn't exist, can someone at least confirm to me that there's no pre-defined function like any/bool_or or all/bool_and to determine if any or all of a boolean column in a group are true (or false)?
For now, my workaround is
select grp_col, count(if(bool_col, true, NULL)) > 0 any_agg
Just take a look at Spark Docs on Aggregate functions section
The list of functions is here under Relational Grouped Dataset - specifically the API's that return DataFrame (not RelationalGroupedDataSet):
https://spark.apache.org/docs/latest/api/scala/index.html?org/apache/spark/sql/RelationalGroupedDataset.html#org.apache.spark.sql.RelationalGroupedDataset

SPARQL Finding the average?

I'm using a SPARQL query tool called Twinkle that doesn't seem to support functions like AVG() and SUM(). So far, only the COUNT() ARQ function works. Is there an alternative way to sum numbers so that I can at least divide using COUNT()?
I don't think so. Switch tools and use something that supports SPARQL 1.1.