Skip to content

Commit

Permalink
Make CAgg error message more clear
Browse files Browse the repository at this point in the history
When creating a Continuous Aggregate we can only reference the primary
hypertable dimension column on the `time_bucket` function, so reworded a
bit the error message to be more clear.
  • Loading branch information
fabriziomello committed Mar 13, 2024
1 parent 8e6994b commit 3ec04e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tsl/src/continuous_aggs/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ caggtimebucket_validate(CAggTimebucketInfo *tbinfo, List *groupClause, List *tar
if (!(IsA(col_arg, Var)) || ((Var *) col_arg)->varattno != tbinfo->htpartcolno)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg(
"time bucket function must reference a hypertable dimension column")));
errmsg("time bucket function must reference the primary hypertable "
"dimension column")));

if (list_length(fe->args) >= 3)
{
Expand Down
8 changes: 4 additions & 4 deletions tsl/test/expected/cagg_errors.out
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ AS
Select max(temperature)
from conditions
group by time_bucket('1week', timemeasure) , location WITH NO DATA;
ERROR: time bucket function must reference a hypertable dimension column
ERROR: time bucket function must reference the primary hypertable dimension column
--time_bucket on expression
CREATE MATERIALIZED VIEW mat_m1 WITH (timescaledb.continuous, timescaledb.materialized_only=false)
AS
Select max(temperature)
from conditions
group by time_bucket('1week', timec+ '10 minutes'::interval) , location WITH NO DATA;
ERROR: time bucket function must reference a hypertable dimension column
ERROR: time bucket function must reference the primary hypertable dimension column
--multiple time_bucket functions
CREATE MATERIALIZED VIEW mat_m1 WITH (timescaledb.continuous, timescaledb.materialized_only=false)
AS
Expand Down Expand Up @@ -369,14 +369,14 @@ as
select time_bucket(100, timec), min(location), sum(temperature),sum(humidity)
from conditions
group by time_bucket(100, timec) WITH NO DATA;
ERROR: time bucket function must reference a hypertable dimension column
ERROR: time bucket function must reference the primary hypertable dimension column
create materialized view mat_with_test( timec, minl, sumt , sumh)
WITH (timescaledb.continuous, timescaledb.materialized_only=false)
as
select time_bucket(100, timec), min(location), sum(temperature),sum(humidity)
from conditions
group by time_bucket(100, timec) WITH NO DATA;
ERROR: time bucket function must reference a hypertable dimension column
ERROR: time bucket function must reference the primary hypertable dimension column
ALTER TABLE conditions ALTER timec type int;
create materialized view mat_with_test( timec, minl, sumt , sumh)
WITH (timescaledb.continuous, timescaledb.materialized_only=false)
Expand Down

0 comments on commit 3ec04e1

Please sign in to comment.