Repository navigation
Conversation
c9d83fe to
3a6b6bf
Compare
ggevay
left a comment
There was a problem hiding this comment.
LGTM, some comments inline. The two sample gaps are the important ones.
(The description says "In PR 3" for the differential testing. SQL-923 has that as PR 5.)
| SqlScalarType::String, | ||
| SqlScalarType::String, | ||
| ])), | ||
| ), |
There was a problem hiding this comment.
This sample doesn't pin string_agg's nullability rule. The output is nullable when the value field inside the input record is nullable (the StringAgg arm of output_sql_type). But record_of makes every field non-null, and output_type_on_nullable_input only makes the outer column nullable. So both output types in the snapshot are String:NotNull, and the test still passes when that arm always returns false or reads the separator field. With a second sample whose value field is nullable, the test fails for both changes:
| ), | |
| ), | |
| aggregate( | |
| AggregateFunc::StringAgg { | |
| order_by: order_by(), | |
| }, | |
| ordered(SqlScalarType::Record { | |
| fields: vec![ | |
| (ColumnName::from("f0"), SqlScalarType::String.nullable(true)), | |
| ( | |
| ColumnName::from("f1"), | |
| SqlScalarType::String.nullable(false), | |
| ), | |
| ] | |
| .into(), | |
| custom_id: None, | |
| }), | |
| ) | |
| .labeled("nullable_value"), |
(Plus a REWRITE=1 run, which adds one record.)
| el_typ: SqlScalarType::Int32, | ||
| }) | ||
| .expect("unnest_list supports WITH ORDINALITY"), | ||
| ), |
There was a problem hiding this comment.
This sample doesn't pin WithOrdinality's empty_on_null_input, which comes from the inner function. unnest_list answers true, so the test still passes when empty_on_null_input is true for every WithOrdinality. abs(x) WITH ORDINALITY would then lose its NULL row, because TableFunc::eval returns no rows for a NULL argument when the property is true. With a second sample over a function that answers false, the test fails for that change:
| ), | |
| ), | |
| table( | |
| TableFunc::with_ordinality(TableFunc::TabletizedScalar { | |
| name: "tabletized".to_string(), | |
| relation: SqlRelationType::new(vec![SqlScalarType::Int32.nullable(true)]), | |
| }) | |
| .expect("tabletized scalars support WITH ORDINALITY"), | |
| ) | |
| .labeled("tabletized"), |
(Plus a REWRITE=1 run.)
| `VariadicFunc`. Run it whenever the diff touches | ||
| `src/expr/src/scalar/func.rs` or `src/expr/src/scalar/func/` (including | ||
| `impls/` and `#[sqlfunc]` bodies): | ||
| `builtin_registry` covers that gap for `UnaryFunc`, `BinaryFunc`, |
There was a problem hiding this comment.
The "New function with a payload" bullet below (line 100) still names only unary_samples(), binary_samples() and variadic_samples(). Could it also name aggregate_samples() and table_samples()?
|
|
||
| # jsonb_each, jsonb_each_text, jsonb_object_keys | ||
|
|
||
| # NOTE: jsonb numbers are normalized, so `1.50` reads back as `1.5`. |
There was a problem hiding this comment.
Besides the jsonb number normalization, this file pins five more differences from PostgreSQL (checked on PostgreSQL 16):
regexp_matcheson a pattern without capture groups returns{}. PostgreSQL returns the whole match, and so does our ownregexp_match(DB-68).- The
jsonb_each*,jsonb_object_keysandjsonb_array_elements*functions return no rows on the wrong kind of jsonb value. PostgreSQL errors (DB-75 coversjsonb_object_keys). jsonb_each ... WITH ORDINALITYnumbers the keys in sorted order. PostgreSQL numbers shorter keys first.- jsonb values print without spaces:
[1,2], where PostgreSQL prints[1, 2](database-issues#7085). aclexplodeof an empty array returns no rows. PostgreSQL errors.
Could each get a NOTE like the one here, so that the goldens don't read as intended behavior?
| # their result and never runs the function. Every call here takes its | ||
| # arguments from a table column, so it runs in a dataflow, which is how a | ||
| # durably stored plan would run it. Rows whose input errors live in their own | ||
| # tables, because one erroring row fails the whole query. |
There was a problem hiding this comment.
Is constant folding a good enough reason for a separate file, as opposed to adding these cases to table_func.slt? And is --auto-index-selects relevant here? table_func.slt is on tests_without_views, so it doesn't run with that flag in PR CI. If the file stays separate, could the header explain why, so that people adding tests later know which file to put theirs in?
3a6b6bf to
ba51ee6
Compare
…yload gate's input Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nctions Adds samples where one sample could not tell a property's branches apart: string_agg over a nullable value field, WITH ORDINALITY over inner functions with keys, broken monotonicity or no empty-on-NULL behavior, fused value window functions with lead and last_value, and min/max/sum at varchar, scaled numeric and precise timestamp inputs. ORDER BY columns and lag/lead values now use types distinct from neighboring fields, so reading the wrong field changes the recorded output type. Notes PostgreSQL differences in table_func_inputs.slt, and why that file runs separately from table_func.slt. Names the aggregate and table sample lists in the mz-commit skill. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ba51ee6 to
ff45564
Compare
QA LLM Review1. MEDIUM -- Aggregate type samples bypass the planner rule that preserves type modifiers
The new varchar, numeric-scale, and timestamp-precision samples call the MIR aggregate typer directly. A change that makes the SQL planner return DetailsSQL resolves the fixed-width character overload at |
Motivation
PR 2 of SQL-923.
Description
The builtin registry now records every aggregate and table function variant alongside the scalar functions, so a change to their recorded properties (null handling, output types, monotonicity, WITH ORDINALITY support) fails the snapshot test. Variants are listed from their serde impls, so adding or removing one also fails it.
Unlike the scalar functions, we don't fingerprint the implementations of
AggregateFuncorTableFunc, because sound coverage would need a compiler-resolved call graph that isn't worth its cost. The newtable_func_inputs.sltruns every table function on edge-case inputs read from tables, so the functions actually execute instead of being constant-folded. PR 6 of SQL-923 adds an upgrade check that runs pinned plans across releases.Verification
Rewrote the registry; new SLT passes (though we don't fingerprint).