@@ -84,7 +84,9 @@ def create_hypertable(table_name,
8484 # @option refresh_policies [String] schedule_interval: INTERVAL
8585 # @option materialized_only [Boolean] Override the WITH clause 'timescaledb.materialized_only'
8686 # @option create_group_indexes [Boolean] Override the WITH clause 'timescaledb.create_group_indexes'
87- # @option finalized [Boolean] Override the WITH clause 'timescaledb.finalized'
87+ # @option finalized [Boolean] Set to false for legacy (non-finalized) format. Note: the finalized
88+ # parameter was removed in TimescaleDB 2.14+ where all aggregates are finalized by default.
89+ # Only use finalized: false on TimescaleDB 2.7-2.13 for legacy compatibility.
8890 #
8991 # @see https://docs.timescale.com/api/latest/continuous-aggregates/create_materialized_view/
9092 # @see https://docs.timescale.com/api/latest/continuous-aggregates/add_continuous_aggregate_policy/
@@ -99,13 +101,17 @@ def create_hypertable(table_name,
99101 # SQL
100102 #
101103 def create_continuous_aggregate ( table_name , query , **options )
104+ # Only include finalized when explicitly false (legacy format).
105+ # The parameter was removed in TimescaleDB 2.14+ where all aggregates are finalized by default.
106+ finalized_clause = options [ :finalized ] == false ? ",timescaledb.finalized=false" : ""
107+
102108 execute <<~SQL
103109 CREATE MATERIALIZED VIEW #{ table_name }
104110 WITH (
105111 timescaledb.continuous
106112 #{ build_with_clause_option_string ( :materialized_only , options ) }
107113 #{ build_with_clause_option_string ( :create_group_indexes , options ) }
108- #{ build_with_clause_option_string ( :finalized , options ) }
114+ #{ finalized_clause }
109115 ) AS
110116 #{ query . respond_to? ( :to_sql ) ? query . to_sql : query }
111117 WITH #{ 'NO' unless options [ :with_data ] } DATA;
0 commit comments