create-in-v0.67.0-object-with-avg.td 1.6 KB

1234567891011121314151617181920212223242526
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. # In v0.67 we changed the way types get promoted in the calculation of AVG(...). As such, we had to
  10. # migrate all existing objects that used the AVG(...) function to a new name, in this case
  11. # AVG_INTERNAL_V1(...), so we could update the implementation of AVG(...).
  12. # Since we're creating in v0.67, these views should not get migrated.
  13. > CREATE VIEW view_with_avg_post_v0_67 (a) AS SELECT avg(position) FROM mz_catalog.mz_columns;
  14. > CREATE MATERIALIZED VIEW mat_view_with_avg_post_v0_67 (a) AS SELECT avg(position) FROM mz_catalog.mz_columns;
  15. # HACK: We create views of the same names in `create-in-v0.27.0-object-with-avg`, when running with
  16. # versions <0.67 those views function calls of AVG(...) should get migrated to use AVG_INTERNAL_V1.
  17. # We skip running that file in versions >=0.67 because then those views would not get migrated, and
  18. # our check in `check-from-v0.67.0-object-with-avg` would not pass. Instead we manually create the
  19. # views with AVG_INTERNAL_V1(...) in versions >=0.67 so our aforementioned check continues to work.
  20. > CREATE VIEW view_with_avg_internal (a) AS SELECT avg_internal_v1(position) FROM mz_catalog.mz_columns;
  21. > CREATE MATERIALIZED VIEW mat_view_with_avg_internal (a) AS SELECT avg_internal_v1(position) FROM mz_catalog.mz_columns;