unsupported foreign call in numeric decoding
()
| 1927 | #[mz_ore::test] |
| 1928 | #[cfg_attr(miri, ignore)] // unsupported foreign call in numeric decoding |
| 1929 | fn test_case_over_jsonb_columns() { |
| 1930 | // Regression test for PER-6: when CASE picks between two JSON columns whose |
| 1931 | // observed keys are disjoint, filter pushdown must not prune parts where |
| 1932 | // accessing a key only present in one branch might yield NULL in the other. |
| 1933 | let arena = RowArena::new(); |
| 1934 | |
| 1935 | // `(CASE WHEN col0 THEN col1 ELSE col2 END) ->> 'y' IS NULL` |
| 1936 | let expr = MirScalarExpr::If { |
| 1937 | cond: Box::new(MirScalarExpr::column(0)), |
| 1938 | then: Box::new(MirScalarExpr::column(1)), |
| 1939 | els: Box::new(MirScalarExpr::column(2)), |
| 1940 | } |
| 1941 | .call_binary( |
| 1942 | MirScalarExpr::literal_ok(Datum::from("y"), ReprScalarType::String), |
| 1943 | JsonbGetStringStringify, |
| 1944 | ) |
| 1945 | .call_unary(UnaryFunc::IsNull(IsNull)); |
| 1946 | |
| 1947 | let relation = ReprRelationType::new(vec![ |
| 1948 | ReprScalarType::Bool.nullable(false), |
| 1949 | ReprScalarType::Jsonb.nullable(false), |
| 1950 | ReprScalarType::Jsonb.nullable(false), |
| 1951 | ]); |
| 1952 | let mut interpreter = ColumnSpecs::new(&relation, &arena); |
| 1953 | interpreter.push_column(0, ResultSpec::value_between(Datum::False, Datum::True)); |
| 1954 | interpreter.push_column( |
| 1955 | 1, |
| 1956 | ResultSpec::map_spec( |
| 1957 | [("x".into(), ResultSpec::value(Datum::String("a")))] |
| 1958 | .into_iter() |
| 1959 | .collect(), |
| 1960 | ), |
| 1961 | ); |
| 1962 | interpreter.push_column( |
| 1963 | 2, |
| 1964 | ResultSpec::map_spec( |
| 1965 | [("y".into(), ResultSpec::value(Datum::String("b")))] |
| 1966 | .into_iter() |
| 1967 | .collect(), |
| 1968 | ), |
| 1969 | ); |
| 1970 | |
| 1971 | let range_out = interpreter.expr(&expr).range; |
| 1972 | // When the CASE selects column 1, "y" is absent and `->> 'y'` yields NULL, so |
| 1973 | // `IS NULL` is True. The filter must not prune a part that could match. |
| 1974 | assert!(range_out.may_contain(Datum::True)); |
| 1975 | } |
| 1976 | |
| 1977 | #[mz_ore::test] |
| 1978 | fn test_like() { |
nothing calls this directly
no test coverage detected