-
Notifications
You must be signed in to change notification settings - Fork 492
[common] Parse datatype from string in DataTypes. #2501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
18b92f3 to
4de9b51
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a string-to-DataType parser to simplify programmatic type definitions in Fluss. The implementation addresses issue #2500, which highlighted the complexity of creating nested row types using Java code by enabling users to parse types from strings instead.
Changes:
- Added
DataTypeParserclass with tokenization and parsing logic for converting string representations to DataType objects - Exposed
DataTypes.parse(String)as the public API entry point - Added comprehensive test suite covering various type parsing scenarios and error cases
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 19 comments.
| File | Description |
|---|---|
| fluss-common/src/main/java/org/apache/fluss/types/DataTypeParser.java | New parser implementation with tokenizer and recursive descent parser for DataType strings |
| fluss-common/src/main/java/org/apache/fluss/types/DataTypes.java | Added public parse() method that delegates to DataTypeParser |
| fluss-common/src/test/java/org/apache/fluss/types/DataTypeParserTests.java | Comprehensive test suite covering parsing, serialization round-trips, and error messages |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| TestSpec.forString("DEC(10, 3)").expectType(new DecimalType(10, 3)), | ||
| TestSpec.forString("NUMERIC(10, 3)").expectType(new DecimalType(10, 3)), | ||
| TestSpec.forString("TINYINT").expectType(new TinyIntType()), | ||
| TestSpec.forString("SMALLINT").expectType(new SmallIntType()), |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This TODO comment suggests there's unfinished work regarding exception handling for "TIMESTAMP WITH TIME ZONE". Either implement the test case or document why this type is not supported and remove the TODO.
4de9b51 to
9db8c69
Compare
Purpose
Linked issue: close #2500
Brief change log
Tests
API and Format
Documentation