You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The cost-based HASH implementation for ordinary window partitions changes existing window results for CHAR keys containing trailing spaces. The legacy SORT path treats the byte-distinct values as separate partition keys, while the new hash path canonicalizes CHAR values by removing trailing spaces and merges them.
CREATEDATABASEm27943_char;
USE m27943_char;
CREATETABLEt(id INT, ch CHAR(8), v INT);
-- Insert 12,000 rows. For each logical key K000..K007, insert 1,363 unpadded-- rows and 137 rows with two trailing spaces; include v as a unique payload.
ANALYZE TABLE t;
SET SESSION agg_spill_mem=1073741824;
EXPLAIN ANALYZE
SELECT id, ch, COUNT(*) OVER (PARTITION BY ch) AS c FROM t;
With the large threshold, EXPLAIN selects Hash Partition. Both K000 and K000 receive count 1,500.
For the same data:
SET SESSION agg_spill_mem=1;
SELECT id, ch, COUNT(*) OVER (PARTITION BY ch) AS c FROM t;
The threshold forces the legacy SORT fallback. K000 receives 1,363 and K000 receives 137 (the corresponding counts are 1,363/137 for every key).
Expected
Changing the physical partition algorithm must not change window partition membership. HASH and SORT should use the same established equality relation, or CHAR should remain on SORT until the comparator and hash semantics are aligned.
Evidence
The difference is deterministic across repeated executions. The hash path uses canonicalVarlenaHashValue in pkg/common/hashmap/strhashmap.go, which strips trailing spaces for T_char; the existing window sort comparator in pkg/compare/strcompare.go compares raw bytes. The result is a user-visible change in COUNT, ranking, and aggregate window functions whenever a CHAR column has trailing-space variants.
Activity