[FLINK-39185][table] Introduce BITMAP type for Table API/SQL#27778
Open
dylanhz wants to merge 2 commits intoapache:masterfrom
Open
[FLINK-39185][table] Introduce BITMAP type for Table API/SQL#27778dylanhz wants to merge 2 commits intoapache:masterfrom
dylanhz wants to merge 2 commits intoapache:masterfrom
Conversation
Collaborator
lincoln-lil
reviewed
Mar 20, 2026
Contributor
lincoln-lil
left a comment
There was a problem hiding this comment.
@dylanhz Thanks for working on this! I've left some comments there, and for the tests, can you add cases covering cast call results, e.g., CAST(bitmap AS STRING) and CAST(bitmap AS VARBINARY).
Another question for the python part, should we adapt bitmap type in PythonTableUtils.converter()?
| * <p>The serializable string representation of this type is {@code BITMAP}. | ||
| */ | ||
| @PublicEvolving | ||
| public final class BitmapType extends LogicalType { |
| } | ||
|
|
||
| /** Gets a copied bitmap. Returns null if {@code other} is null. */ | ||
| static Bitmap from(Bitmap other) { |
Contributor
There was a problem hiding this comment.
We should at least add java doc here to clearly note that currently only RoaringBitmapData is supported
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of the change
This pull request adds Table API/SQL support for the BITMAP data type introduced in FLIP-556. It integrates BITMAP into Flink's type system, internal data format, planner, and code generation, enabling BITMAP columns to be used in SQL queries and Table API programs.
This is the third PR in the FLIP-556 series:
FLINK-39183): Parser supportFLINK-39184): DataStream API support (flink-core)FLINK-39185): Table API/SQL support (this PR)Brief change log
Suggested review order:
BitmapType,LogicalTypeRoot.BITMAP,LogicalTypeFamily.EXTENSION, visitor support, cast rules, and type parsingDataTypes.BITMAP(), registered type mappings inClassDataTypeConverter,TypeInfoDataTypeConverter, andValueDataTypeConverterRowData/ArrayDatawithgetBitmap(), implemented inBinaryRowData/BinaryArrayData/GenericRowData/GenericArrayData/NestedRowData; addedBinarySegmentUtils.readBitmap()andBinaryWriter.writeBitmap()BitmapRelDataType, integrated intoFlinkTypeFactory(bidirectional conversion betweenBitmapTypeandBitmapRelDataType), extendedCodeGenUtilsfor code generation, and updatedExpressionReducerBitmapToStringCastRuleandBitmapToBinaryCastRule(with trim/pad semantics); restrictedCAST(x AS BITMAP)inSqlCastFunctionBitmapBitmapConverter,DataFormatConverters.BitmapConverter, and JSON serialization/deserialization forBitmapTypeVerifying this change
This change added tests and can be verified as follows:
BitmapSemanticTest: End-to-end integration tests for BITMAP in SQL/Table API, covering source/sink roundtrip, projection, filtering, UDF invocation, and UDAF aggregationBinaryRowDataTest/BinaryArrayDataTest: Unit tests for BITMAP read/write in binary row and array formatsRowDataTest: Verifies BITMAP field access andFieldGetterinRowDataDataTypesTest: VerifiesDataTypes.BITMAP()resolution and class mappingLogicalTypesTest: TestsBitmapTypeproperties, serialization string, and cast compatibilityProjectionCodeGeneratorTest: Verifies BITMAP field projection in generated codeTypeInferenceExtractorTest: Tests type inference for UDFs that accept/return BITMAP, including rejection of custom Bitmap implementationsDoes this pull request potentially affect one of the following parts:
@Public(Evolving): yes (RowData,ArrayData,DataTypes,BinaryWriter)getBitmap/writeBitmapcode paths, but only activated for BITMAP type columns)Documentation