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
BigQuery supports two flavors of CASE.
The regular is analogous to Clojure's 'cond' - where we provide pairs of condition and expression, with the optional default expression at the end.
I'm happy to add support for this. :case is currently "special syntax" so I'll make that into a reusable function and add :case-expr (which I think is more expressive and more accurate than :case-val since it accepts an expression).
(deftesttest-case-expr
(is (= ["SELECT CASE foo WHEN ? THEN ? WHEN ? THEN foo / ? ELSE ? END FROM bar"1-1220]
(sut/format
{:select [[[:case-expr:foo1-12 [:/:foo2]
:else0]]]
:from [:bar]}))))
BigQuery supports two flavors of CASE.
The regular is analogous to Clojure's 'cond' - where we provide pairs of condition and expression, with the optional default expression at the end.
The second flavor is similar to Clojure's 'case' - where we provide a single expression and then pairs of value and expression, with the optional default expression at the end.
https://cloud.google.com/bigquery/docs/reference/standard-sql/conditional_expressions#case_expr
So, one can provide something that computes a value once and then based on the result value provides the target value ( or default ).
I am wondering how could this be supported? For example something like:
[:case-val my-expression
1 "foo"
2 "bar"
"baz" ]
Is it something that better be added internally, or should a user registered op be constructed ?
The text was updated successfully, but these errors were encountered: