Skip to content

Commit

Permalink
Make RowType::nameOf throw Velox exception (#11336)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #11336

So we can have a stacktrace and easier to debug.

Reviewed By: bikramSingh91

Differential Revision: D64845329

fbshipit-source-id: 4677589e21e8cf71d0112e886b5af56d89e88267
  • Loading branch information
Yuhta authored and facebook-github-bot committed Oct 23, 2024
1 parent 14a74eb commit 97aa713
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion velox/type/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,8 @@ class RowType : public TypeBase<TypeKind::ROW> {
std::optional<uint32_t> getChildIdxIfExists(const std::string& name) const;

const std::string& nameOf(uint32_t idx) const {
return names_.at(idx);
VELOX_CHECK_LT(idx, names_.size());
return names_[idx];
}

bool equivalent(const Type& other) const override;
Expand Down
2 changes: 1 addition & 1 deletion velox/type/tests/TypeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ TEST(TypeTest, row) {
EXPECT_STREQ(row0->findChild("a")->kindName(), "INTEGER");
EXPECT_EQ(row0->nameOf(0), "a");
EXPECT_EQ(row0->nameOf(1), "b");
EXPECT_THROW(row0->nameOf(4), std::out_of_range);
EXPECT_THROW(row0->nameOf(4), VeloxRuntimeError);
EXPECT_THROW(row0->findChild("not_exist"), VeloxUserError);
// todo: expected case behavior?:
VELOX_ASSERT_THROW(
Expand Down

0 comments on commit 97aa713

Please sign in to comment.