Commit 4006498f authored by Paul Asmuth's avatar Paul Asmuth
Browse files

more error handling...

parent 8aeb5f17
Loading
Loading
Loading
Loading
+20 −2
Original line number Diff line number Diff line
@@ -872,6 +872,24 @@ TEST_CASE(QueryTest, TestSimpleAggregateFromCSV, [] () {
  EXPECT(std::stof(results->getRow(0)[0]) == 74209240);
});

TEST_CASE(QueryTest, TestNoSuchColumnError, [] () {
  EXPECT_EXCEPTION("no such column: 'fnord'", [] () {
    auto csv_table = new csv_backend::CSVTableRef(
        csv_backend::CSVInputStream::openFile(
            "test/fixtures/gbp_per_country_simple.csv"), 
        true);

    TableRepository repo;
    repo.addTableRef("gbp_per_country",
        std::unique_ptr<csv_backend::CSVTableRef>(csv_table));

    auto query = Query(
        "  SELECT"
        "    sum(fnord) as global_gbp"
        "  FROM"
        "    gbp_per_country;",
        &repo);
    query.execute();
  });
});
+5 −1
Original line number Diff line number Diff line
@@ -52,7 +52,11 @@ Executable* QueryPlan::buildQueryPlan(ASTNode* ast, TableRepository* repo) {
    return exec;
  }

  assert(0); // FIXPAUL cant build queryplan
  // if verbose -> dump ast

  RAISE(
      util::RuntimeException,
      "can't figure out a query plan for this, sorry :(");
}

bool QueryPlan::hasGroupByClause(ASTNode* ast) {
+5 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#include "tablerepository.h"
#include "compile.h"
#include "execute.h"
#include <fnordmetric/util/runtimeexception.h>

namespace fnordmetric {
namespace query {
@@ -167,7 +168,10 @@ protected:

      auto col_index = tbl_ref->getColumnIndex(token->getString());
      if (col_index < 0) {
        printf("error: column not found: %s\n", token->getString().c_str());
        RAISE(
            util::RuntimeException,
            "no such column: '%s'",
            token->getString().c_str());
        return false;
      }