mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-30 11:36:54 +00:00
hierarchy with expressions' from Avi Kivity Currently, the grammar has two parallel hierarchies. One hierarchy is used in the WHERE clause, and is based on a combination of `term` and expressions. The other is used in the SELECT clause, and is using the cql3::selection::selectable hierarchy. There is some overlap between the hierarchies: both can name columns. Logically, however, they overlap completely - in SQL anything you can select you can filter on, and vice versa. So merging the two hierarchies is important if we want to enrich CQL. This series does that, partially (see below), converting the SELECT clause to expressions. There is another hierarchy split: between the "raw", pre-prepare object hierarchy, and post-prepare non-raw. This series limits itself to converting the raw hierarchy and leaves the non-raw hierarchy alone. An important design choice is not to have this raw/non-raw split in expressions. Note that most of the hierarchy is completely parallel: addition is addition both before prepare and after prepare (but see [1]). The main difference is around identifiers - before preparation they are unresolved, and after preparation they become `column_definition` objects. We resolve that by having two separate types: `unresolved_identifier` for the pre-prepare phase, and the existing `column_value` for post-prepare phase. Alternative choices would be to keep a separate expression::raw variant, or to template the expression variant on whether it is raw or not. I think it would cause undue bloat and confusion. Note the series introduces many on_internal_error() calls. This is because there is not a lot of overlap in the hierarchies today; you can't have a cast in the WHERE clause, for example. These on_internal_error() calls cannot be triggered since the grammar does not yet allow such expressions to be expressed. As we expand the grammar, they will have to be replaced with working implementations. Lastly, field selection is expressible in both hierarchies. This series does not yet merge the two representations (`column_value.sub` vs `field_selection`), but it should be easy to do so later. [1] the `+` operator can also be translated to list concatenation, which we may choose to represent by yet another type. Test: unit(dev) Closes #9087 * github.com:scylladb/scylla: cql3: expression: update find_atom, count_if for function_call, cast, field_selection cql3: expressions: fix printing of nested expressions cql3: selection: replace selectable::raw with expression cql3: expression: convert selectable::with_field_selection::raw to expression cql3: expression: convert selectable::with_cast::raw to expression cql3: expression: convert selectable::with_anonymous_function::raw to expression cql3: expression: convert selectable::with_function_call::raw to expressions cql3: selectable: make selectable::raw forward-declarable cql3: expressions: convert writetime_or_ttl::raw to expression cql3: expression: add convenience constructor from expression element to nested expression utils: introduce variant_element.hh cql3: expression: use nested_expression in binary_operator cql3: expression: introduce nested_expression class Convert column_identifier_raw's use as selectable to expressions make column_identifier::raw forward declarable cql3: introduce selectable::with_expression::raw