Skip to content

Commit

Permalink
deploy: eec8d93
Browse files Browse the repository at this point in the history
  • Loading branch information
jjbayer committed Sep 6, 2023
1 parent 0c65f74 commit a32279d
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,24 @@
<a href="#564" id="564">564</a>
<a href="#565" id="565">565</a>
<a href="#566" id="566">566</a>
<a href="#567" id="567">567</a>
<a href="#568" id="568">568</a>
<a href="#569" id="569">569</a>
<a href="#570" id="570">570</a>
<a href="#571" id="571">571</a>
<a href="#572" id="572">572</a>
<a href="#573" id="573">573</a>
<a href="#574" id="574">574</a>
<a href="#575" id="575">575</a>
<a href="#576" id="576">576</a>
<a href="#577" id="577">577</a>
<a href="#578" id="578">578</a>
<a href="#579" id="579">579</a>
<a href="#580" id="580">580</a>
<a href="#581" id="581">581</a>
<a href="#582" id="582">582</a>
<a href="#583" id="583">583</a>
<a href="#584" id="584">584</a>
</pre></div><pre class="rust"><code><span class="doccomment">//! Logic for scrubbing and normalizing span descriptions that contain SQL queries.
</span><span class="kw">mod </span>parser;
<span class="kw">pub use </span>parser::parse_query;
Expand Down Expand Up @@ -1124,6 +1142,24 @@
<span class="string">&quot;SELECT %s; SELECT %s&quot;
</span>);

<span class="macro">scrub_sql_test!</span>(
case_when,
<span class="string">&quot;UPDATE tbl SET foo = CASE WHEN 1 THEN 10 WHEN 2 THEN 20 ELSE 30 END&quot;</span>,
<span class="string">&quot;UPDATE tbl SET foo = CASE WHEN .. THEN .. END&quot;
</span>);

<span class="macro">scrub_sql_test!</span>(
case_when_nested,
<span class="string">r#&quot;UPDATE
tbl
SET &quot;tbl&quot;.&quot;foo&quot; = CASE
WHEN 1 THEN 10
WHEN 2 THEN (CASE WHEN 22 THEN 222 END)
ELSE 30
END&quot;#</span>,
<span class="string">&quot;UPDATE tbl SET foo = CASE WHEN .. THEN .. END&quot;
</span>);

<span class="macro">scrub_sql_test!</span>(
clickhouse,
<span class="string">&quot;SELECT (toStartOfHour(finish_ts, &#39;Universal&#39;) AS _snuba_time), (uniqIf((nullIf(user, &#39;&#39;) AS _snuba_user), greater(multiIf(equals(tupleElement((&#39;duration&#39;, 300), 1), &#39;lcp&#39;), (if(has(measurements.key, &#39;lcp&#39;), arrayElement(measurements.value, indexOf(measurements.key, &#39;lcp&#39;)), NULL) AS `_snuba_measurements[lcp]`), (duration AS _snuba_duration)), multiply(tupleElement((&#39;duration&#39;, 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((&#39;duration&#39;, 300), 1), &#39;lcp&#39;), `_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((&#39;transaction&#39; AS _snuba_type), &#39;transaction&#39;) AND greaterOrEquals((finish_ts AS _snuba_finish_ts), toDateTime(&#39;2023-06-13T09:08:51&#39;, &#39;Universal&#39;)) AND less(_snuba_finish_ts, toDateTime(&#39;2023-07-11T09:08:51&#39;, &#39;Universal&#39;)) AND in((project_id AS _snuba_project_id), [123, 456, 789]) AND equals((environment AS _snuba_environment), &#39;production&#39;) GROUP BY _snuba_time ORDER BY _snuba_time ASC LIMIT 10000 OFFSET 0&quot;</span>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,18 @@
<a href="#280" id="280">280</a>
<a href="#281" id="281">281</a>
<a href="#282" id="282">282</a>
<a href="#283" id="283">283</a>
<a href="#284" id="284">284</a>
<a href="#285" id="285">285</a>
<a href="#286" id="286">286</a>
<a href="#287" id="287">287</a>
<a href="#288" id="288">288</a>
<a href="#289" id="289">289</a>
<a href="#290" id="290">290</a>
<a href="#291" id="291">291</a>
<a href="#292" id="292">292</a>
<a href="#293" id="293">293</a>
<a href="#294" id="294">294</a>
</pre></div><pre class="rust"><code><span class="doccomment">//! Logic for parsing SQL queries and manipulating the resulting Abstract Syntax Tree.
</span><span class="kw">use </span>std::ops::ControlFlow;

Expand Down Expand Up @@ -448,6 +460,18 @@
<span class="kw-2">*</span>expr = Expr::Value(<span class="self">Self</span>::placeholder())
}
}
<span class="comment">// Simplify `CASE WHEN..` expressions.
</span>Expr::Case {
operand,
conditions,
results,
else_result,
} =&gt; {
operand.take();
<span class="kw-2">*</span>conditions = <span class="macro">vec!</span>[Expr::Identifier(<span class="self">Self</span>::ellipsis())];
<span class="kw-2">*</span>results = <span class="macro">vec!</span>[Expr::Identifier(<span class="self">Self</span>::ellipsis())];
else_result.take();
}
<span class="kw">_ </span>=&gt; {}
}
ControlFlow::Continue(())
Expand Down

0 comments on commit a32279d

Please sign in to comment.