danny0405 opened a new pull request, #20390: URL: https://github.com/apache/hudi/pull/20390
### Describe the issue this Pull Request addresses Hive meta-sync inserts partition values and directory locations directly into Hive SQL string literals. A partition value such as `O'Reilly` closes the literal early and makes the generated DDL invalid; backslashes can also change the value interpreted by Hive. SQL-like partition text can consequently be interpreted as SQL syntax rather than data. This affects the shared query-based partition builder used by JDBC and HiveQL sync modes. The HMS executor does not use this builder. ### Summary and Changelog - Reuse `HiveSchemaUtil.escapeSqlString` for partition values after optional URL decoding, covering ADD, SET LOCATION, and TOUCH statements. - Escape the full physical location in both ADD and SET LOCATION statements without URL-decoding the directory path. - Add eight parameterized regression cases using Hive's parser and literal decoder to verify that generated DDL preserves quotes, backslashes, trailing backslashes, encoded values with decoding enabled and disabled, and SQL-like text. Every case exercises all three operations and a base path containing a quote and backslash. - No code was copied from external projects. ### Impact JDBC and HiveQL partition synchronization preserves special characters as literal data. This changes no public APIs, configuration defaults, or storage formats. HMS behavior is unchanged. Escaping adds a small amount of string processing while constructing DDL; no performance benchmark was run. ### Risk Level low The change is limited to three literal-construction sites and reuses the escaping helper already used for Hive comments and properties. Parser regression tests check that partition values and physical locations round-trip unchanged, including when partition decoding is enabled. Validation on Java 11: ```sh mvn -o -pl hudi-sync/hudi-hive-sync -Dtest=TestQueryBasedDDLExecutorEscaping,TestQueryBasedDDLExecutorTouchBatching,TestHiveSchemaUtil test ``` All 19 focused tests passed, including eight new regression cases. The new tests reproduced failures before the fix. Maven Checkstyle and `git diff --check` passed. A live Hive/JDBC integration test and the full project test suite were not run. ### Documentation Update none — this restores correct handling of existing partition values and paths and introduces no feature, configuration, or default change. ### Contributor's checklist - [x] Read through [contributor's guide](https://hudi.apache.org/contribute/how-to-contribute) - [x] Enough context is provided in the sections above - [x] Adequate tests were added if applicable -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
