Class: Sequel::Funky::FunkySpark
- Defined in:
- lib/sequel/extensions/funky.rb
Instance Method Summary collapse
- #collect_list(column) ⇒ Object
- #hash ⇒ Object
- #make_json_column(ds, key_column, value_column) ⇒ Object
-
#str_to_date(value, format, try: false) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
Methods inherited from FunkyBase
#from_strptime, #initialize, #to_strptime
Constructor Details
This class inherits a constructor from Sequel::Funky::FunkyBase
Instance Method Details
#collect_list(column) ⇒ Object
63 64 65 |
# File 'lib/sequel/extensions/funky.rb', line 63 def collect_list(column) Sequel.function(:collect_list, column) end |
#hash ⇒ Object
31 32 33 |
# File 'lib/sequel/extensions/funky.rb', line 31 def hash(*) Sequel.function(:xxhash64, *) end |
#make_json_column(ds, key_column, value_column) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/sequel/extensions/funky.rb', line 35 def make_json_column(ds, key_column, value_column) json_object_col = Sequel.function( :named_struct, 'key', key_column, 'value', value_column, ).then do |json_object_col| Sequel.function( :collect_list, json_object_col, ) end.then do |list_col| Sequel.function( :map_from_entries, list_col, ) end.then do |map_from_entries_col| Sequel.function( :to_json, map_from_entries_col, ) end ds.from_self .select(json_object_col) .limit(1) end |
#str_to_date(value, format, try: false) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
27 28 29 |
# File 'lib/sequel/extensions/funky.rb', line 27 def str_to_date(value, format, try: false) # rubocop:disable Lint/UnusedMethodArgument Sequel.function(:to_date, Sequel.cast_string(value), format) end |