diff --git a/relay-general/src/store/normalize/span/description.rs b/relay-general/src/store/normalize/span/description.rs index 32e888d9c6..c05f4b91d1 100644 --- a/relay-general/src/store/normalize/span/description.rs +++ b/relay-general/src/store/normalize/span/description.rs @@ -23,11 +23,11 @@ static SQL_NORMALIZER_REGEX: Lazy = Lazy::new(|| { # Capture `SAVEPOINT` savepoints. ((?-x)SAVEPOINT (?P(?:(?:"[^"]+")|(?:'[^']+')|(?:`[^`]+`)|(?:[a-z]\w+)))) | # Capture single-quoted strings, including the remaining substring if `\'` is found. - ((?-x)(?P'(?:\\'|[^'])*(?:'|$))) | + ((?-x)(?P'(?:\\'|[^'])*(?:'|$)(::\w+(\[\]?)?)?)) | # Capture placeholders. - ((?-x)(?P(?:\?+|\$\d+))) | + ( (?P (?:\?+|\$\d+|%s) (::\w+(\[\]?)?)? ) ) | # Capture numbers. - ((?-x)(?P(-?\b(?:[0-9]+\.)?[0-9]+(?:[eE][+-]?[0-9]+)?\b))) | + ((?-x)(?P(-?\b(?:[0-9]+\.)?[0-9]+(?:[eE][+-]?[0-9]+)?\b)(::\w+(\[\]?)?)?)) | # Capture booleans (as full tokens, not as substrings of other tokens). ((?-x)(?P(\b(?:true|false)\b))) "#, @@ -590,6 +590,13 @@ mod tests { "INSERT INTO a (b, c, d, e) VALuES (%s) ON CONFLICT DO NOTHING" ); + span_description_test!( + span_description_scrub_type_casts, + "INSERT INTO a (b, c, d) VALUES ('foo'::date, 123::bigint[], %s::bigint[])", + "db.sql.query", + "INSERT INTO a (b, c, d) VALUES (%s)" + ); + span_description_test!( span_description_scrub_clickhouse, "SELECT (toStartOfHour(finish_ts, 'Universal') AS _snuba_time), (uniqIf((nullIf(user, '') AS _snuba_user), greater(multiIf(equals(tupleElement(('duration', 300), 1), 'lcp'), (if(has(measurements.key, 'lcp'), arrayElement(measurements.value, indexOf(measurements.key, 'lcp')), NULL) AS `_snuba_measurements[lcp]`), (duration AS _snuba_duration)), multiply(tupleElement(('duration', 300), 2), 4))) AS _snuba_count_miserable_user), (ifNull(divide(plus(_snuba_count_miserable_user, 4.56), plus(nullIf(uniqIf(_snuba_user, greater(multiIf(equals(tupleElement(('duration', 300), 1), 'lcp'), `_snuba_measurements[lcp]`, _snuba_duration), 0)), 0), 113.45)), 0) AS _snuba_user_misery), _snuba_count_miserable_user, (divide(countIf(notEquals(transaction_status, 0) AND notEquals(transaction_status, 1) AND notEquals(transaction_status, 2)), count()) AS _snuba_failure_rate), (divide(count(), divide(3600.0, 60)) AS _snuba_tpm_3600) FROM transactions_dist WHERE equals(('transaction' AS _snuba_type), 'transaction') AND greaterOrEquals((finish_ts AS _snuba_finish_ts), toDateTime('2023-06-13T09:08:51', 'Universal')) AND less(_snuba_finish_ts, toDateTime('2023-07-11T09:08:51', 'Universal')) AND in((project_id AS _snuba_project_id), [123, 456, 789]) AND equals((environment AS _snuba_environment), 'production') GROUP BY _snuba_time ORDER BY _snuba_time ASC LIMIT 10000 OFFSET 0",