Skip to main content

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:
  1. Default Location: $STARROCKS_HOME/lib/type_checker_config.xml
  2. Relative Fallback: lib/type_checker_config.xml (if STARROCKS_HOME is not set)
IMPORTANT: XML configuration is mandatory. The configuration file must exist at one of the above locations. If the file is not found or fails to parse, the system will log errors and continue with an empty checker map (default checker handles unknown types).

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 class
    • java_class attribute: Fully qualified Java class name (e.g., java.lang.Integer)
    • display_name attribute: Human-readable name used in error messages
  • <type-rule>: Defines an allowed type conversion rule
    • allowed_type attribute: StarRocks type that can accept this Java type (e.g., TYPE_INT)
    • return_type attribute: 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 default lib/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)
See lib/type_checker_config.xml for the complete configuration.

Usage

For Administrators

  1. 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
  2. Custom Configuration
  3. 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

  1. Create a test XML configuration:
  1. Verify loading:

Adding Custom Type Mappings

To add a new type mapping:
  1. Edit your XML configuration file (or lib/type_checker_config.xml)
  2. Add a new <type-mapping> element with appropriate type rules:
  3. Restart StarRocks BE
  4. Verify loading in BE logs
No C++ code changes required - all type checking logic is in the XML configuration!

Best Practices

  1. Version Control: Keep your XML configuration in version control
  2. Validation: Validate XML changes before deployment using XML validators
  3. Comments: Use XML comments to document custom type mappings
  4. Testing: Test configuration changes in a non-production environment first
  5. Backup: Keep a backup of working configuration before making changes
  6. Documentation: Document any custom type rules and their rationale

Troubleshooting

Configuration Not Loading

  1. Check environment variable:
  2. Verify file exists and has correct permissions:
  3. Check BE logs for error messages
  4. Validate XML syntax:

Type Checker Not Working

  1. Verify the Java class name is correct in XML (case-sensitive, fully qualified)
  2. Ensure the display_name attribute is present
  3. Check that at least one <type-rule> element is defined
  4. Verify type names match exactly (e.g., TYPE_INT not int)
  5. Review BE logs for warnings about failed checker creation

XML Parsing Errors

  1. Ensure XML is well-formed (matching open/close tags)
  2. Verify all attributes are properly quoted
  3. Check for special characters that need escaping
  4. Use XML validator: xmllint lib/type_checker_config.xml

Migration from Previous Versions

If you’re upgrading from a version with hardcoded type checkers:
  1. XML Configuration is Now Mandatory: Ensure lib/type_checker_config.xml exists
  2. No Hardcoded Fallback: The system will not fall back to hardcoded configuration
  3. New XML Format: Update any custom XML to use <type-rule> elements instead of checker attribute
  4. 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 rules
  • TypeCheckerXMLLoader: Parses XML using libxml2 and creates ConfigurableTypeChecker instances
  • TypeCheckerManager: Manages type checker registry and routes type checking requests
All type validation logic is now data-driven via XML configuration, eliminating the need for specialized type checker classes.

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