From 88213931ea88b21ea25e32bad1d7297fa6650434 Mon Sep 17 00:00:00 2001 From: Tilmann Singer Date: Thu, 24 Jun 2021 16:09:53 +0200 Subject: [PATCH] Do not attempt to coerce a value when NULL Previously, a query such as SELECT CAST(NULL AS timestamp) resulted in an "no implicit conversion of nil into String" error due to the attempt to parse `nil` as time. Also do not set numeric values to 0 or 0.0 when NULL. --- lib/blazer/adapters/athena_adapter.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/blazer/adapters/athena_adapter.rb b/lib/blazer/adapters/athena_adapter.rb index 31c118ce0..33ba6a5ef 100644 --- a/lib/blazer/adapters/athena_adapter.rb +++ b/lib/blazer/adapters/athena_adapter.rb @@ -62,19 +62,19 @@ def run_statement(statement, comment) case ct when "timestamp" rows.each do |row| - row[i] = utc.parse(row[i]) + row[i] &&= utc.parse(row[i]) end when "date" rows.each do |row| - row[i] = Date.parse(row[i]) + row[i] &&= Date.parse(row[i]) end when "bigint" rows.each do |row| - row[i] = row[i].to_i + row[i] &&= row[i].to_i end when "double" rows.each do |row| - row[i] = row[i].to_f + row[i] &&= row[i].to_f end end end