davydog187/timescale

Discussion: Should we support positional arguments for optional arguments?

davydog187 opened this issue · 2 comments

For functions like time_bucket, optional arguments can be passed as named arguments, but they can be passed positionally.

Should we support both? CC: @akoutmos

SELECT time_bucket('5 minutes', time, '-2.5 minutes'::INTERVAL) + '2.5 minutes'
  AS five_min, avg(cpu)
FROM metrics
GROUP BY five_min
ORDER BY five_min DESC LIMIT 10;

We can definitely do that. Those functions can be simple passthroughs to the named argument versions so that we can lean on the same types of validations/type castings in the queries. We'll need to make sure that all of our arguments (both required and optional) align in terms of ordering and name in the documentation so that there is no confusion for library users what positional arguments are.

For example, I think for the time bucket one functions, I made the column name the first arg, but it is actually the second arg in the TimescaleDB function. Same with the first and last functions. The argument names differ from the TimescaleDB docs and we will want to be more consistent.

Very good point @akoutmos, completely agree with that path