Skip to content

Commit

Permalink
Better function-not-found error messages (#344)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #344

Improve error messages when (1) scalar or aggregate function doesn't exit or
doesn't support specified input types; (2) SQL expression has syntax errors.

Before:

- Cannot resolve function call: sum(BIGINT)
- Cannot resolve function call: from_unixtime(BIGINT)
- Parser Error: syntax error at or near "b"

After:

- Aggregate function doesn't exist: sum. Registry of aggregate functions is empty. Make sure to register some aggregate functions.
- Scalar function signature is not supported: to_unixtime(BIGINT). Supported signatures: (row(bigint,smallint)) -> double, (timestamp) -> double.
- Cannot parse expression: func(a b). Parser Error: syntax error at or near "b"

X-link: facebookincubator/velox#1685

Reviewed By: kagamiori

Differential Revision: D36630439

Pulled By: mbasmanova

fbshipit-source-id: 0ee4db468bb7c718371184ca29d1237279820760
  • Loading branch information
mbasmanova authored and facebook-github-bot committed May 25, 2022
1 parent a71f34c commit 4d94688
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions csrc/velox/functions/rec/tests/BucketizeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "pytorch/torcharrow/csrc/velox/functions/functions.h"
#include "velox/functions/prestosql/tests/FunctionBaseTest.h"
#include "velox/parse/TypeResolver.h"

namespace facebook::velox {
namespace {
Expand All @@ -28,6 +29,7 @@ class BucketizeTest : public functions::test::FunctionBaseTest {
protected:
static void SetUpTestCase() {
torcharrow::functions::registerTorchArrowFunctions();
parse::registerTypeResolver();
}

template <typename T, typename T1 = T, typename TExpected = T>
Expand Down
2 changes: 2 additions & 0 deletions csrc/velox/functions/rec/tests/ComputeScoreTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "pytorch/torcharrow/csrc/velox/functions/functions.h"
#include "velox/functions/prestosql/tests/FunctionBaseTest.h"
#include "velox/parse/TypeResolver.h"

namespace facebook::velox {
namespace {
Expand All @@ -42,6 +43,7 @@ class ComputeScoreTest : public functions::test::FunctionBaseTest {
std::vector<std::vector<float>> matchingIdScoresVec;
static void SetUpTestCase() {
torcharrow::functions::registerTorchArrowFunctions();
parse::registerTypeResolver();
}

virtual void SetUp() override {
Expand Down
2 changes: 2 additions & 0 deletions csrc/velox/functions/rec/tests/FirstXTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "pytorch/torcharrow/csrc/velox/functions/functions.h"
#include "velox/functions/prestosql/tests/FunctionBaseTest.h"
#include "velox/parse/TypeResolver.h"

namespace facebook::velox {
namespace {
Expand All @@ -28,6 +29,7 @@ class firstXTest : public functions::test::FunctionBaseTest {
protected:
static void SetUpTestCase() {
torcharrow::functions::registerTorchArrowFunctions();
parse::registerTypeResolver();
}
};

Expand Down
2 changes: 2 additions & 0 deletions csrc/velox/functions/rec/tests/SigridHashTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "pytorch/torcharrow/csrc/velox/functions/functions.h"
#include "velox/functions/prestosql/tests/FunctionBaseTest.h"
#include "velox/parse/TypeResolver.h"

namespace facebook::velox {
namespace {
Expand All @@ -28,6 +29,7 @@ class SigridHashTest : public functions::test::FunctionBaseTest {
protected:
static void SetUpTestCase() {
torcharrow::functions::registerTorchArrowFunctions();
parse::registerTypeResolver();
}

template <typename T, typename T1 = T, typename TExpected = T>
Expand Down
6 changes: 4 additions & 2 deletions csrc/velox/functions/tests/FunctionsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <velox/vector/SimpleVector.h>
#include "pytorch/torcharrow/csrc/velox/functions/functions.h"
#include "velox/functions/prestosql/tests/FunctionBaseTest.h"
#include "velox/parse/TypeResolver.h"

namespace facebook::velox {
namespace {
Expand All @@ -33,6 +34,7 @@ class FunctionsTest : public functions::test::FunctionBaseTest {
protected:
static void SetUpTestCase() {
torcharrow::functions::registerTorchArrowFunctions();
parse::registerTypeResolver();
}

template <typename T>
Expand Down Expand Up @@ -242,7 +244,7 @@ TEST_F(FunctionsTest, bitwise_and) {
"torcharrow_bitwiseand(c0, c1)",
{1.2},
{-3.4},
"Cannot resolve function call: torcharrow_bitwiseand(REAL, REAL)");
"Scalar function signature is not supported: torcharrow_bitwiseand(REAL, REAL).");
}

TEST_F(FunctionsTest, bitwise_or) {
Expand Down Expand Up @@ -279,7 +281,7 @@ TEST_F(FunctionsTest, bitwise_or) {
"torcharrow_bitwiseor(c0, c1)",
{1.2},
{-3.4},
"Cannot resolve function call: torcharrow_bitwiseor(REAL, REAL)");
"Scalar function signature is not supported: torcharrow_bitwiseor(REAL, REAL).");
}

TEST_F(FunctionsTest, round) {
Expand Down

0 comments on commit 4d94688

Please sign in to comment.