def _hash_val(col_idx, val):
  """Compute a numeric hash of 'val', which is at column index 'col_idx'."""
  if val is None:
    # The hash() of None can change from run to run since it's based on
    # a memory address. A chosen value will be used instead.
    val = 38463209
  elif isinstance(val, float):
    # Floats returned by Impala may not be deterministic, the ending
    # insignificant digits may differ. Only the first 6 digits will be used
    # after rounding.
    sval = "%f" % val
    dot_idx = sval.find(".")
    val = round(val, 6 - dot_idx)
  return (col_idx + 1) * hash(val)