message: refactor the comparison code to compare results
diff: @@ -7,20 +7,31 @@ try:
  except:
  can_run = False
  +def answer_munge(cell):
  + try:
  + cell = round(float(cell), 2)
  + except ValueError:
  + cell = str(cell)
  + return cell
  +
  +def result_munge(cell):
  + try:
  + cell = round(float(cell), 2)
  + except (ValueError, TypeError):
  + cell = str(cell)
  + return cell
  def check_result(result,answers):
  for q_res in answers:
  db_result = result.fetchone()
  cq_results = q_res.split("|")
  - i = 0
  - for cq_res in cq_results:
  - if cq_res != str(db_result[i]):
  - if cq_res == '' and str(db_result[i]) == 'None':
  + # The end of the rows, continue
  + if cq_results == [''] and str(db_result) == 'None' or str(db_result[0]) == 'None':
  continue
  - #AVG does floating point division, check only first 6 values
  - if (float(cq_res[0:6]) != float(str(db_result[i])[0:6])):
  - return False
  - i = i+1
  + ans_result = [answer_munge(cell) for cell in cq_results]
  + db_result = [result_munge(cell) for cell in db_result]
  +
  + assert ans_result == db_result
  return True
  class TestTPCHArrow(object):
  @@ -44,7 +55,7 @@ class TestTPCHArrow(object):
  for i in range (1,23):
  query = duckdb_conn.execute("select query from tpch_queries() where query_nr="+str(i)).fetchone()[0]
  - answers = duckdb_conn.execute("select answer from tpch_answers() where scale_factor = 0.01 and query_nr="+str(i)).fetchone()[1:]
  + answers = duckdb_conn.execute("select answer from tpch_answers() where scale_factor = 0.01 and query_nr="+str(i)).fetchone()[0].split("\n")[1:]
  result = duckdb_conn.execute(query)
  assert(check_result(result,answers))
  print ("Query " + str(i) + " works")
  @@ -68,7 +79,7 @@ class TestTPCHArrow(object):
  for i in range (1,23):
  query = duckdb_conn.execute("select query from tpch_queries() where query_nr="+str(i)).fetchone()[0]
  - answers = duckdb_conn.execute("select answer from tpch_answers() where scale_factor = 0.01 and query_nr="+str(i)).fetchone()[1:]
  + answers = duckdb_conn.execute("select answer from tpch_answers() where scale_factor = 0.01 and query_nr="+str(i)).fetchone()[0].split("\n")[1:]
  result = duckdb_conn.execute(query)
  assert(check_result(result,answers))
  print ("Query " + str(i) + " works")
  @@ -78,7 +89,7 @@ class TestTPCHArrow(object):
  for i in range (1,23):
  query = duckdb_conn.execute("select query from tpch_queries() where query_nr="+str(i)).fetchone()[0]
  - answers = duckdb_conn.execute("select answer from tpch_answers() where scale_factor = 0.01 and query_nr="+str(i)).fetchone()[1:]
  + answers = duckdb_conn.execute("select answer from tpch_answers() where scale_factor = 0.01 and query_nr="+str(i)).fetchone()[0].split("\n")[1:]
  result = duckdb_conn.execute(query)
  assert(check_result(result,answers))
  print ("Query " + str(i) + " works (Parallel)")
  