Skip to content

Commit 5c49d35

Browse files
committed
Allow Spark identifiers to start with numbers
Refs #859
1 parent 2f206d1 commit 5c49d35

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/languages/spark/spark.formatter.ts

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ export const spark: DialectOptions = {
139139
{ quote: '""-raw', prefixes: ['R', 'X'], requirePrefix: true },
140140
],
141141
identTypes: ['``'],
142+
identChars: { allowFirstCharNumber: true },
142143
variableTypes: [{ quote: '{}', prefixes: ['$'], requirePrefix: true }],
143144
operators: ['%', '~', '^', '|', '&', '<=>', '==', '!', '||', '->'],
144145
postProcess,

test/spark.test.ts

+13
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,19 @@ describe('SparkFormatter', () => {
6262
supportsLimiting(format, { limit: true });
6363
supportsDataTypeCase(format);
6464

65+
// regression test for #859
66+
it('supports identifiers that start with numbers', () => {
67+
expect(format('SELECT 4four, 12345e FROM 5tbl')).toBe(
68+
dedent`
69+
SELECT
70+
4four,
71+
12345e
72+
FROM
73+
5tbl
74+
`
75+
);
76+
});
77+
6578
it('formats basic WINDOW clause', () => {
6679
const result = format(`SELECT * FROM tbl WINDOW win1, WINDOW win2, WINDOW win3;`);
6780
expect(result).toBe(dedent`

0 commit comments

Comments
 (0)