Overview
The StarRocks Type Checker system uses mandatory XML-based configuration for defining Java type to StarRocks logical type mappings. All type checkers are now defined via XML with configurable type rules, providing maximum flexibility and maintainability without requiring code changes or recompilation.Features
- Fully XML-Configurable: All type mappings defined in XML with explicit type validation rules
- Industry-Standard Parser: Uses libxml2 for robust, standards-compliant XML parsing
- No Hardcoded Fallback: XML configuration is mandatory - ensures all type mappings are explicitly defined
- Flexible Type Rules: Each type can have multiple type-rule mappings for different StarRocks types
- Extensible: Easy to add new type mappings or modify existing ones via XML
- Validated: Comprehensive error checking for malformed XML or invalid configurations
Configuration File Location
The type checker configuration is loaded from the following location:-
Default Location:
$STARROCKS_HOME/lib/type_checker_config.xml -
Relative Fallback:
lib/type_checker_config.xml(ifSTARROCKS_HOMEis not set)
XML Configuration Format
Structure with Type Rules
All type checkers now use a configurable format with explicit type-rule elements:XML Elements
<type-checkers>: Root element containing all type mappings<type-mapping>: Defines a mapping for a specific Java classjava_classattribute: Fully qualified Java class name (e.g.,java.lang.Integer)display_nameattribute: Human-readable name used in error messages
<type-rule>: Defines an allowed type conversion ruleallowed_typeattribute: StarRocks type that can accept this Java type (e.g.,TYPE_INT)return_typeattribute: StarRocks type to return for this conversion
Example Configuration
Supported StarRocks Types
The following StarRocks logical types can be used in type rules:Default Type Mappings
The defaultlib/type_checker_config.xml includes mappings for:
- Java Primitives: Byte, Short, Integer, Long, Boolean, Float, Double
- Java Objects: String, BigInteger, BigDecimal
- Temporal Types: java.sql.Date, java.sql.Time, java.sql.Timestamp, java.time.LocalDate, java.time.LocalDateTime
- Binary Types: byte[], [B, java.util.UUID
- Database-Specific: Oracle (TIMESTAMP, TIMESTAMPLTZ, TIMESTAMPTZ, OracleBlob), SQL Server (DateTimeOffset), ClickHouse (UnsignedByte, UnsignedShort, UnsignedInteger, UnsignedLong)
lib/type_checker_config.xml for the complete configuration.
Usage
For Administrators
-
Using Default Configuration
- The default configuration is provided at
lib/type_checker_config.xml - Ensure this file exists before starting StarRocks BE
- No additional setup required if using standard type mappings
- The default configuration is provided at
-
Custom Configuration
-
Validation
- Check BE logs for configuration loading messages:
- Or for errors:
For Developers
The type checker system is used automatically when processing JDBC query results:Error Handling
The XML loader provides detailed error messages for common issues:Missing Configuration File
Malformed XML
Missing Attributes
Invalid Type Names
Empty Configuration
Testing
Unit Tests
Run the type checker tests:Manual Testing
- Create a test XML configuration:
- Verify loading:
Adding Custom Type Mappings
To add a new type mapping:- Edit your XML configuration file (or
lib/type_checker_config.xml) - Add a new
<type-mapping>element with appropriate type rules: - Restart StarRocks BE
- Verify loading in BE logs
Best Practices
- Version Control: Keep your XML configuration in version control
- Validation: Validate XML changes before deployment using XML validators
- Comments: Use XML comments to document custom type mappings
- Testing: Test configuration changes in a non-production environment first
- Backup: Keep a backup of working configuration before making changes
- Documentation: Document any custom type rules and their rationale
Troubleshooting
Configuration Not Loading
-
Check environment variable:
-
Verify file exists and has correct permissions:
- Check BE logs for error messages
-
Validate XML syntax:
Type Checker Not Working
- Verify the Java class name is correct in XML (case-sensitive, fully qualified)
- Ensure the
display_nameattribute is present - Check that at least one
<type-rule>element is defined - Verify type names match exactly (e.g.,
TYPE_INTnotint) - Review BE logs for warnings about failed checker creation
XML Parsing Errors
- Ensure XML is well-formed (matching open/close tags)
- Verify all attributes are properly quoted
- Check for special characters that need escaping
- Use XML validator:
xmllint lib/type_checker_config.xml
Migration from Previous Versions
If you’re upgrading from a version with hardcoded type checkers:- XML Configuration is Now Mandatory: Ensure
lib/type_checker_config.xmlexists - No Hardcoded Fallback: The system will not fall back to hardcoded configuration
- New XML Format: Update any custom XML to use
<type-rule>elements instead ofcheckerattribute - Verify Configuration: Test your XML configuration before deployment
Old Format (No Longer Supported)
New Format (Required)
Architecture
The type checker system consists of:ConfigurableTypeChecker: Single type checker class that validates based on configured rulesTypeCheckerXMLLoader: Parses XML using libxml2 and creates ConfigurableTypeChecker instancesTypeCheckerManager: Manages type checker registry and routes type checking requests
See Also
- Type Checker Implementation:
be/src/types/checker/type_checker.h - XML Loader:
be/src/types/checker/type_checker_xml_loader.h - Type Checker Manager:
be/src/types/type_checker_manager.h - Default Configuration:
lib/type_checker_config.xml - Unit Tests:
be/test/types/type_checker_test.cpp,be/test/types/type_checker_xml_loader_test.cpp