Skip to content

Commit 0a5f430

Browse files
committed
Test JDBC-compatible catalog backslash handling
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
1 parent fbd37bb commit 0a5f430

4 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎lib/utils/escapeCatalogName.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
/** Escape catalog underscores without double-escaping existing `\_` sequences. */
1+
/**
2+
* Match JDBC by preserving immediate `\_` pairs, even after another backslash.
3+
*/
24
export default function escapeCatalogName(catalogName: string | undefined): string | undefined {
35
if (catalogName == null) {
46
return catalogName;

‎tests/unit/kernel/execution.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,7 @@ describe('KernelSessionBackend', () => {
11021102
['main', 'main'],
11031103
['comparator_tests', 'comparator\\_tests'],
11041104
['a\\_b_c', 'a\\_b\\_c'],
1105+
[String.raw`my\\_cat`, String.raw`my\\_cat`],
11051106
['a_b%c', 'a\\_b%c'],
11061107
['%', '%'],
11071108
]) {

‎tests/unit/thrift-backend/ThriftCatalogEscaping.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ describe('Thrift metadata catalog escaping', () => {
1717
['_a__b_', '\\_a\\_\\_b\\_'],
1818
['comparator\\_tests', 'comparator\\_tests'],
1919
['a\\_b_c', 'a\\_b\\_c'],
20+
[String.raw`my\\_cat`, String.raw`my\\_cat`],
2021
['a_b%c', 'a\\_b%c'],
2122
['%', '%'],
2223
]) {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { expect } from 'chai';
2+
import escapeCatalogName from '../../../lib/utils/escapeCatalogName';
3+
4+
describe('escapeCatalogName JDBC compatibility', () => {
5+
it('preserves two backslashes before an underscore, matching JDBC', () => {
6+
const catalogName = String.raw`my\\_cat`;
7+
expect(escapeCatalogName(catalogName)).to.equal(catalogName);
8+
});
9+
});

0 commit comments

Comments
 (0)