sap hana dialect added#276
Conversation
|
Thanks for opening the PR. Please remove to .opencode directory and the AGENTS.md, as I do not want to include them in this project. |
|
Hi, what about the openspec definitions. Should they stay or go as well? |
Yes, please remove them as well, thanks |
|
Thanks for the SAP HANA dialect contribution. I reviewed the PR locally and the core direction looks useful, especially for HANA-to-Trino migration workflows. I would ask for a few changes before merging. What I checked locally: The HANA custom fixtures passed: 132 identity cases and 80 transpilation cases. The feature-gated Rust/WASM/FFI checks above also passed. Main points to address:
Overall: this is a valuable addition, but I would not merge it as-is. Once the date-format semantics, HANA identity scope, generator scoping, and PR hygiene are cleaned up, this should be much easier to review and likely merge. |
1. Changes
HanaDialectto support SAP HANA Cloud SQL, including tokenizer and generator configurations (Oracle-style identifiers, string quoting, uppercase keywords).transform_expr()andtransform_function()to map ~40 HANA-specific functions to generic AST nodes so they correctly generate Trino SQL. This includes date arithmetic (ADD_DAYS,MONTHS_BETWEEN), string operations (LCASE,LOCATE), null handling (NVL,IFNULL), and datetime constants (CURRENT_UTCTIMESTAMP).convert_hana_to_java_format()to translate HANA's Oracle-style date format tokens (e.g.,YYYY,HH24,MI,PM) into JavaSimpleDateFormattokens (e.g.,yyyy,HH,mm,a), specifically forDATE_FORMATandDATE_PARSEcompatibility in Trino.DataType::Customlogic ingenerator.rsto correctly map proprietary HANA types (SMALLDECIMAL,SECONDDATE,ALPHANUM,CLOB, etc.) to standard equivalents (DECIMAL,TIMESTAMP,VARCHAR) while preserving scale, precision, and length arguments.identity.json,transpilation.json,types.json,functions.json,ddl.json,dml.json) to verify parsing logic and Trino translations.2. Impact
TrinoDialectsimply pass through unmodified, keeping theHanaDialectfootprint small and safe.3. What to Watch Out For on Review
LOCATE(substr, str)while Trino usesSTRPOS(str, substr). Verify the parameter extraction and swapping logic insidetransform_function("LOCATE")correctly handles the semantic difference.FLOATimplies 64-bit precision. Verify the logic translatingDataType::Float { real_spelling: false }intoDataType::Doublemeets interoperability expectations without losing precision.TOKENSarray inconvert_hana_to_java_format(). Ensure all critical HANA date tokens map accurately and that the loop appropriately skips and preserves unknown or literal characters safely.generator.rs, ensure that when proprietary types likeALPHANUM(n)orSMALLDECIMAL(p, s)are mapped toVARCHAR(n)andDECIMAL(p, s), the parser arguments string (_args_str) is being securely appended after the generic type name keyword.