 #include <cuda_runtime.h>
 #include "hash/groupby_compute_api.h"
 #include "hash/aggregation_operations.cuh"
+#include "../gdf_table.cuh"
 
 /* --------------------------------------------------------------------------*/
 /** 

  // FIXME When the aggregation type is COUNT, use the type of the OUTPUT column
  // as the type of the aggregation column. This is required as there is a limitation 
  // hash based groupby implementation where it's assumed the aggregation input column
  if(is_same_functor<count_op, op>::value)
  {
    aggregation_column_type = out_aggregation_column->dtype;

 * @Returns On failure, returns appropriate error code. Otherwise, GDF_SUCCESS
 */
/* ----------------------------------------------------------------------------*/
template <typename aggregation_type, 
          template <typename T> class op,
          typename size_type>
gdf_error typed_groupby(gdf_table<size_type> const & groupby_input_table,
                        gdf_column* in_aggregation_column,       
                        gdf_table<size_type> & groupby_output_table,
                        gdf_column* out_aggregation_column,
                        bool sort_result = false)
{
  // Template the functor on the type of the aggregation column
  using op_type = op<aggregation_type>;

  // Cast the void* data to the appropriate type
  aggregation_type * in_agg_col = static_cast<aggregation_type *>(in_aggregation_column->data);
  // TODO Need to allow for the aggregation output type to be different from the aggregation input type
  aggregation_type * out_agg_col = static_cast<aggregation_type *>(out_aggregation_column->data);

  size_type output_size{0};

  if(cudaSuccess != GroupbyHash(groupby_input_table, 
                                in_agg_col, 
                                groupby_output_table, 
                                out_agg_col, 
                                &output_size, 
                                op_type(), 
                                sort_result))
  {
    return GDF_CUDA_ERROR;
  }

  // Update the size of the result
  groupby_output_table.set_column_length(output_size);
  out_aggregation_column->size = output_size;

  return GDF_SUCCESS;
}
