Skip to content

Commit 88af221

Browse files
SteNicholasclaude
andcommitted
feat(types): support CHAR/VARCHAR/BINARY/VARBINARY in data type json parser
Previously CHAR/VARCHAR/BINARY/VARBINARY were registered as keywords but had no handling branch in ParseTypeByKeyword, so deserializing a schema that contained them failed with "Unsupported type: VARCHAR". Map CHAR/VARCHAR to arrow::utf8() and BINARY/VARBINARY to arrow::binary() (consistent with STRING and BYTES), parsing and discarding the optional length parameter. Add parser test cases covering these types with and without a length argument. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent b631683 commit 88af221

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/paimon/common/types/data_type_json_parser.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,12 @@ Result<std::shared_ptr<arrow::DataType>> TokenParser::ParseTypeWithNullability(b
465465
Result<std::shared_ptr<arrow::DataType>> TokenParser::ParseTypeByKeyword(bool* is_blob) {
466466
PAIMON_RETURN_NOT_OK(NextToken(TokenType::KEYWORD));
467467
switch (TokenAsKeyword()) {
468+
case Keyword::CHAR:
469+
case Keyword::VARCHAR:
470+
return ParseStringType<arrow::StringType>();
471+
case Keyword::BINARY:
472+
case Keyword::VARBINARY:
473+
return ParseStringType<arrow::BinaryType>();
468474
case Keyword::BYTES:
469475
return arrow::binary();
470476
case Keyword::BLOB: {

src/paimon/common/types/data_type_json_parser_test.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ TEST(DataTypeJsonParserTest, ParseTypeAtomicTypeSuccess) {
111111
{"TIMESTAMP_LTZ(9)", arrow::timestamp(arrow::TimeUnit::NANO, timezone)},
112112
{"BYTES", arrow::binary()},
113113
{"STRING", arrow::utf8()},
114+
{"CHAR", arrow::utf8()},
115+
{"CHAR(10)", arrow::utf8()},
116+
{"VARCHAR", arrow::utf8()},
117+
{"VARCHAR(10)", arrow::utf8()},
118+
{"BINARY", arrow::binary()},
119+
{"BINARY(10)", arrow::binary()},
120+
{"VARBINARY", arrow::binary()},
121+
{"VARBINARY(10)", arrow::binary()},
114122
};
115123

116124
for (const auto& test_case : test_cases) {

0 commit comments

Comments
 (0)