Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE committed Feb 12, 2024
1 parent ec8f612 commit 31bdabb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
4 changes: 2 additions & 2 deletions velox/vector/arrow/Bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ const char* exportArrowFormatStr(
return "u"; // utf-8 string
case TypeKind::VARBINARY:
return "z"; // binary
case TypeKind::UNKNOWN:
return "n"; // NullType

case TypeKind::TIMESTAMP:
return "ttn"; // time64 [nanoseconds]
Expand All @@ -259,8 +261,6 @@ const char* exportArrowFormatStr(
return "+m"; // map
case TypeKind::ROW:
return "+s"; // struct
case TypeKind::UNKNOWN:
return "n";

default:
VELOX_NYI("Unable to map type '{}' to ArrowSchema.", type->kind());
Expand Down
21 changes: 6 additions & 15 deletions velox/vector/arrow/tests/ArrowBridgeSchemaTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ TEST_F(ArrowBridgeSchemaExportTest, scalar) {

testScalarType(DECIMAL(10, 4), "d:10,4");
testScalarType(DECIMAL(20, 15), "d:20,15");

testScalarType(UNKNOWN(), "n");
}

TEST_F(ArrowBridgeSchemaExportTest, nested) {
Expand Down Expand Up @@ -238,25 +240,14 @@ TEST_F(ArrowBridgeSchemaExportTest, constant) {
testConstant(DOUBLE(), "g");
testConstant(VARCHAR(), "u");
testConstant(DATE(), "tdD");
testConstant(UNKNOWN(), "n");

testConstant(ARRAY(INTEGER()), "+l");
testConstant(ARRAY(UNKNOWN()), "+l");
testConstant(MAP(BOOLEAN(), REAL()), "+m");
testConstant(MAP(UNKNOWN(), REAL()), "+m");
testConstant(ROW({TIMESTAMP(), DOUBLE()}), "+s");
}

TEST_F(ArrowBridgeSchemaExportTest, unsupported) {
GTEST_SKIP() << "Skipping it, cause unknown type supported";
// Try some combination of unsupported types to ensure there's no crash or
// memory leak in failure scenarios.
EXPECT_THROW(testScalarType(UNKNOWN(), ""), VeloxException);

EXPECT_THROW(testScalarType(ARRAY(UNKNOWN()), ""), VeloxException);
EXPECT_THROW(testScalarType(MAP(UNKNOWN(), INTEGER()), ""), VeloxException);
EXPECT_THROW(testScalarType(MAP(BIGINT(), UNKNOWN()), ""), VeloxException);

EXPECT_THROW(testScalarType(ROW({BIGINT(), UNKNOWN()}), ""), VeloxException);
EXPECT_THROW(
testScalarType(ROW({BIGINT(), REAL(), UNKNOWN()}), ""), VeloxException);
testConstant(ROW({UNKNOWN(), UNKNOWN()}), "+s");
}

class ArrowBridgeSchemaImportTest : public ArrowBridgeSchemaExportTest {
Expand Down

0 comments on commit 31bdabb

Please sign in to comment.