Module: ActiveRecord::ConnectionAdapters::ClickHouse::RelationDictionaries
- Defined in:
- lib/active_record/connection_adapters/clickhouse/querying.rb
Overview
Projects a dictionary lookup alongside the row — dictGet replaces the dimension JOIN of a star schema. Dictionary/attribute names travel as quoted string literals; only the alias needs identifier validation.
Instance Method Summary collapse
- #dict_get(dictionary, attribute, key:, as: nil, default: nil) ⇒ Object
- #dict_get!(dictionary, attribute, key:, as: nil, default: nil) ⇒ Object
Instance Method Details
#dict_get(dictionary, attribute, key:, as: nil, default: nil) ⇒ Object
211 212 213 |
# File 'lib/active_record/connection_adapters/clickhouse/querying.rb', line 211 def dict_get(dictionary, attribute, key:, as: nil, default: nil) spawn.dict_get!(dictionary, attribute, key: key, as: as, default: default) end |
#dict_get!(dictionary, attribute, key:, as: nil, default: nil) ⇒ Object
215 216 217 218 219 220 221 222 223 224 |
# File 'lib/active_record/connection_adapters/clickhouse/querying.rb', line 215 def dict_get!(dictionary, attribute, key:, as: nil, default: nil) alias_name = (as || attribute).to_s raise ArgumentError, "dict_get alias must be an identifier" unless RelationWindowing::WINDOW_IDENTIFIER.match?(alias_name) self.select_values += [klass.arel_table[::Arel.star]] if select_values.empty? self.select_values += [::Arel::Nodes::As.new(dict_get_node(dictionary, attribute, key, default), ::Arel.sql(alias_name))] self end |