crystal-cassandra icon indicating copy to clipboard operation
crystal-cassandra copied to clipboard

UDT erroring

Open jself opened this issue 5 years ago • 3 comments
trafficstars

Hello, I'm getting an error on a user defined frozen hash field. The error is:

Unhandled exception: Missing hash key: ValueTypeUdt (KeyError)
  from /usr/lib/crystal/hash.cr:1027:11 in '[]'
  from lib/cassandra/src/cassandra/dbapi/decoders.cr:47:11 in 'get_decoder'
  from lib/cassandra/src/cassandra/dbapi/decoders.cr:297:11 in 'decode_with_type'
  from lib/cassandra/src/cassandra/dbapi/decoders.cr:13:13 in 'decode'
  from lib/cassandra/src/cassandra/dbapi/result_set.cr:126:9 in 'read'
  from lib/db/src/db/result_set.cr:79:15 in 'read'
  from src/ip-affinities.cr:17:18 in '__crystal_main'
  from /usr/lib/crystal/crystal/main.cr:105:5 in 'main_user_code'
  from /usr/lib/crystal/crystal/main.cr:91:7 in 'main'
  from /usr/lib/crystal/crystal/main.cr:114:3 in 'main'
  from __libc_start_main
  from _start
  from ???

The actual field causing the issue is defined as: site_sections map<text, frozen<engagement_data>>,

engagement_data is defined as:

create type engagement_data (
	first_seen timestamp,
	last_seen timestamp,
	blink_total int,
	scan_total int,
	read_total int,
	score float,
	total_seconds int,
	total_read_seconds int
);

We have a lot of these nested custom types. Is there any way to allow them? Sorry if I'm missing something apparent, I'm also a crystal newb. The actual crystal code causing the issue is:

def get_sections(db, did)
  db.query("select did, site_sections from users where did=?", did) do |res|
    res.each do
      did = res.read(String)
      sections = res.read(Any)
      yield sections
    end
  end
end

jself avatar May 29 '20 18:05 jself

User defined types have not been implemented, I never needed them personally.

kaukas avatar May 30 '20 11:05 kaukas

@jself I am also running into the same issue. How did you end up solving this?

munjalpatel avatar Dec 10 '20 02:12 munjalpatel

@munjalpatel I just stopped using Crystal and moved to Rust. I didn't know it that well anyway. Sorry. :(

jself avatar Dec 10 '20 04:12 jself