@@ -14,6 +14,10 @@ exec-ddl
14
14
CREATE TABLE c (a BOOL, b BOOL, c BOOL, d BOOL, e BOOL)
15
15
----
16
16
17
+ exec-ddl
18
+ CREATE TABLE d (k INT PRIMARY KEY, a INT NOT NULL, b INT, c INT, d FLOAT)
19
+ ----
20
+
17
21
exec-ddl
18
22
CREATE TABLE e
19
23
(
@@ -1638,6 +1642,144 @@ exec-ddl
1638
1642
DROP INDEX partial_idx
1639
1643
----
1640
1644
1645
+ # --------------------------------------------------
1646
+ # SimplifyIsCondition
1647
+ # --------------------------------------------------
1648
+
1649
+ norm expect=SimplifyIsCondition
1650
+ SELECT * FROM d WHERE a = 1 AND k IS NOT DISTINCT FROM 1 AND d = 1.0
1651
+ ----
1652
+ select
1653
+ ├── columns: k:1!null a:2!null b:3 c:4 d:5!null
1654
+ ├── cardinality: [0 - 1]
1655
+ ├── key: ()
1656
+ ├── fd: ()-->(1-5)
1657
+ ├── scan d
1658
+ │ ├── columns: k:1!null a:2!null b:3 c:4 d:5
1659
+ │ ├── key: (1)
1660
+ │ └── fd: (1)-->(2-5)
1661
+ └── filters
1662
+ ├── a:2 = 1 [outer=(2), constraints=(/2: [/1 - /1]; tight), fd=()-->(2)]
1663
+ ├── k:1 = 1 [outer=(1), constraints=(/1: [/1 - /1]; tight), fd=()-->(1)]
1664
+ └── d:5 = 1.0 [outer=(5), constraints=(/5: [/1.0 - /1.0]; tight), fd=()-->(5)]
1665
+
1666
+ # The rule applies if at least one of the operands is non-nullable.
1667
+ norm expect=SimplifyIsCondition
1668
+ SELECT * FROM d WHERE a IS NOT DISTINCT FROM b
1669
+ ----
1670
+ select
1671
+ ├── columns: k:1!null a:2!null b:3!null c:4 d:5
1672
+ ├── key: (1)
1673
+ ├── fd: (1)-->(2-5), (2)==(3), (3)==(2)
1674
+ ├── scan d
1675
+ │ ├── columns: k:1!null a:2!null b:3 c:4 d:5
1676
+ │ ├── key: (1)
1677
+ │ └── fd: (1)-->(2-5)
1678
+ └── filters
1679
+ └── a:2 = b:3 [outer=(2,3), constraints=(/2: (/NULL - ]; /3: (/NULL - ]), fd=(2)==(3), (3)==(2)]
1680
+
1681
+ # The rule does not apply if both operands are nullable.
1682
+ norm expect-not=SimplifyIsCondition
1683
+ SELECT * FROM d WHERE b IS NOT DISTINCT FROM NULL
1684
+ ----
1685
+ select
1686
+ ├── columns: k:1!null a:2!null b:3 c:4 d:5
1687
+ ├── key: (1)
1688
+ ├── fd: ()-->(3), (1)-->(2,4,5)
1689
+ ├── scan d
1690
+ │ ├── columns: k:1!null a:2!null b:3 c:4 d:5
1691
+ │ ├── key: (1)
1692
+ │ └── fd: (1)-->(2-5)
1693
+ └── filters
1694
+ └── b:3 IS NULL [outer=(3), constraints=(/3: [/NULL - /NULL]; tight), fd=()-->(3)]
1695
+
1696
+ norm expect-not=SimplifyIsCondition
1697
+ SELECT * FROM d WHERE NULL IS NOT DISTINCT FROM b
1698
+ ----
1699
+ select
1700
+ ├── columns: k:1!null a:2!null b:3 c:4 d:5
1701
+ ├── key: (1)
1702
+ ├── fd: ()-->(3), (1)-->(2,4,5)
1703
+ ├── scan d
1704
+ │ ├── columns: k:1!null a:2!null b:3 c:4 d:5
1705
+ │ ├── key: (1)
1706
+ │ └── fd: (1)-->(2-5)
1707
+ └── filters
1708
+ └── b:3 IS NULL [outer=(3), constraints=(/3: [/NULL - /NULL]; tight), fd=()-->(3)]
1709
+
1710
+ norm expect-not=SimplifyIsCondition
1711
+ SELECT * FROM d WHERE b IS NOT DISTINCT FROM c
1712
+ ----
1713
+ select
1714
+ ├── columns: k:1!null a:2!null b:3 c:4 d:5
1715
+ ├── key: (1)
1716
+ ├── fd: (1)-->(2-5)
1717
+ ├── scan d
1718
+ │ ├── columns: k:1!null a:2!null b:3 c:4 d:5
1719
+ │ ├── key: (1)
1720
+ │ └── fd: (1)-->(2-5)
1721
+ └── filters
1722
+ └── b:3 IS NOT DISTINCT FROM c:4 [outer=(3,4)]
1723
+
1724
+ norm expect-not=SimplifyIsCondition
1725
+ SELECT * FROM d WHERE b IS NULL
1726
+ ----
1727
+ select
1728
+ ├── columns: k:1!null a:2!null b:3 c:4 d:5
1729
+ ├── key: (1)
1730
+ ├── fd: ()-->(3), (1)-->(2,4,5)
1731
+ ├── scan d
1732
+ │ ├── columns: k:1!null a:2!null b:3 c:4 d:5
1733
+ │ ├── key: (1)
1734
+ │ └── fd: (1)-->(2-5)
1735
+ └── filters
1736
+ └── b:3 IS NULL [outer=(3), constraints=(/3: [/NULL - /NULL]; tight), fd=()-->(3)]
1737
+
1738
+ # The rule does not apply if the operands are tuples.
1739
+ norm expect-not=SimplifyIsCondition
1740
+ SELECT * FROM d WHERE (k, a) IS NOT DISTINCT FROM (a, k)
1741
+ ----
1742
+ select
1743
+ ├── columns: k:1!null a:2!null b:3 c:4 d:5
1744
+ ├── immutable
1745
+ ├── key: (1)
1746
+ ├── fd: (1)-->(2-5)
1747
+ ├── scan d
1748
+ │ ├── columns: k:1!null a:2!null b:3 c:4 d:5
1749
+ │ ├── key: (1)
1750
+ │ └── fd: (1)-->(2-5)
1751
+ └── filters
1752
+ └── (k:1, a:2) IS NOT DISTINCT FROM (a:2, k:1) [outer=(1,2), immutable]
1753
+
1754
+ # The rule does not apply if the operands do not have identical types.
1755
+ norm expect-not=SimplifyIsCondition
1756
+ SELECT * FROM d WHERE a IS NOT DISTINCT FROM 1.23
1757
+ ----
1758
+ select
1759
+ ├── columns: k:1!null a:2!null b:3 c:4 d:5
1760
+ ├── key: (1)
1761
+ ├── fd: (1)-->(2-5)
1762
+ ├── scan d
1763
+ │ ├── columns: k:1!null a:2!null b:3 c:4 d:5
1764
+ │ ├── key: (1)
1765
+ │ └── fd: (1)-->(2-5)
1766
+ └── filters
1767
+ └── a:2 IS NOT DISTINCT FROM 1.23 [outer=(2)]
1768
+
1769
+ norm expect-not=SimplifyIsCondition
1770
+ SELECT * FROM d WHERE a IS NOT DISTINCT FROM d
1771
+ ----
1772
+ select
1773
+ ├── columns: k:1!null a:2!null b:3 c:4 d:5
1774
+ ├── key: (1)
1775
+ ├── fd: (1)-->(2-5)
1776
+ ├── scan d
1777
+ │ ├── columns: k:1!null a:2!null b:3 c:4 d:5
1778
+ │ ├── key: (1)
1779
+ │ └── fd: (1)-->(2-5)
1780
+ └── filters
1781
+ └── a:2 IS NOT DISTINCT FROM d:5 [outer=(2,5)]
1782
+
1641
1783
# --------------------------------------------------
1642
1784
# PushSelectIntoProjectSet
1643
1785
# --------------------------------------------------
0 commit comments