datafusion-comet
datafusion-comet copied to clipboard
feat: Use enum to represent CAST eval_mode in expr.proto
Which issue does this PR close?
Closes #361
Rationale for this change
The updates to expr.proto by using enums instead of strings, which prevents potential errors in type interpretation. Modifications in planner.rs and QueryPlanSerde.scala resolve issues found during compilation and style checks.
What changes are included in this PR?
expr.proto: Updated theeval_modefield from a string type to an enum type (EvalMode), with defined valuesLEGACY,TRY, andANSI.- Rust Code: Modified
ExprStruct::Cast(expr)inplanner.rsto handleeval_modeas integers corresponding to the new protobuf enum. Updated the match statement to directly convert integers to the EvalMode Rust enum and added error handling for invalid integers. QueryPlanSerde.scala:- Introduced the
stringToEvalModefunction, which converts input strings toExprOuterClass.EvalModeenum values using a case-insensitive match, enhancing our error handling by throwing exceptions for invalid modes. - Corrected the use of
toUpperCaseto includeLocale.ROOTto avoid locale-sensitive behavior, aligning with internationalization best practices. - Reorganized imports to comply with project's Scalastyle guidelines, clearly separating Java standard library imports from those specific to the project, which aids in code clarity and maintenance.
- Addressed and resolved Scalastyle violations related to locale-specific string manipulations. Fixed the Scalastyle violation by correcting the usage of
toUpperCasewithout specifying a locale. Reorganized import statements to adhere to the project's coding standards, ensuring that Java standard library imports are correctly grouped.
- Introduced the
How are these changes tested?
I have run
make test-rust: No failures.make test-jvm: No failures.