123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- # Copyright Materialize, Inc. and contributors. All rights reserved.
- #
- # Use of this software is governed by the Business Source License
- # included in the LICENSE file at the root of this repository.
- #
- # As of the Change Date specified in that file, in accordance with
- # the Business Source License, use of this software will be governed
- # by the Apache License, Version 2.0.
- from textwrap import dedent
- from materialize.checks.actions import Testdrive
- from materialize.checks.checks import Check
- class NullValue(Check):
- def initialize(self) -> Testdrive:
- return Testdrive(
- dedent(
- """
- > CREATE TABLE null_value_table (f1 INTEGER, f2 INTEGER DEFAULT NULL);
- > INSERT INTO null_value_table DEFAULT VALUES;
- > INSERT INTO null_value_table VALUES (NULL, NULL);
- > INSERT INTO null_value_table VALUES (NULL, NULL);
- """
- )
- )
- def manipulate(self) -> list[Testdrive]:
- return [
- Testdrive(dedent(s))
- for s in [
- """
- > CREATE VIEW null_value_view1 AS
- SELECT f1, f2, NULL
- FROM null_value_table
- WHERE f1 IS NULL OR f1 IS NOT NULL OR f1 = NULL;
- > INSERT INTO null_value_table SELECT * FROM null_value_table;
- """,
- """
- > CREATE MATERIALIZED VIEW null_value_view2 AS
- SELECT f1, f2, NULL
- FROM null_value_table
- WHERE f1 IS NULL OR f1 IS NOT NULL OR f1 = NULL;
- > INSERT INTO null_value_table SELECT * FROM null_value_table;
- """,
- ]
- ]
- def validate(self) -> Testdrive:
- return Testdrive(
- dedent(
- """
- > SELECT * FROM null_value_view1;
- <null> <null> <null>
- <null> <null> <null>
- <null> <null> <null>
- <null> <null> <null>
- <null> <null> <null>
- <null> <null> <null>
- <null> <null> <null>
- <null> <null> <null>
- <null> <null> <null>
- <null> <null> <null>
- <null> <null> <null>
- <null> <null> <null>
- > SELECT * FROM null_value_view2;
- <null> <null> <null>
- <null> <null> <null>
- <null> <null> <null>
- <null> <null> <null>
- <null> <null> <null>
- <null> <null> <null>
- <null> <null> <null>
- <null> <null> <null>
- <null> <null> <null>
- <null> <null> <null>
- <null> <null> <null>
- <null> <null> <null>
- """
- )
- )
|