Skip to content

Commit 598a604

Browse files
committed
fix: double quoted table mentions in athena and tsql
1 parent 69bbc58 commit 598a604

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

pegjs/athena.pegjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2242,7 +2242,7 @@ literal_string
22422242
value: ca[1].join('')
22432243
};
22442244
}
2245-
/ ca:("\"" single_quote_char* "\"") {
2245+
/ ca:("\"" single_quote_char* "\"") !DOT {
22462246
return {
22472247
type: 'double_quote_string',
22482248
value: ca[1].join('')

pegjs/transactsql.pegjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2838,7 +2838,7 @@ literal_string
28382838
value: ca[1].join(''),
28392839
};
28402840
}
2841-
/ ca:("\"" single_quote_char* "\"") {
2841+
/ ca:("\"" single_quote_char* "\"") !DOT {
28422842
return {
28432843
type: 'double_quote_string',
28442844
value: ca[1].join('')

test/athena.spec.js

+7
Original file line numberDiff line numberDiff line change
@@ -338,4 +338,11 @@ describe('athena', () => {
338338
GROUP BY id`
339339
expect(getParsedSql(sql)).to.be.equal("SELECT `id`, array_agg(json_extract_scalar(`elem`, '$.value')) AS `er_teams` FROM `bronze_prod`.`jira_issues` CROSS JOIN UNNEST(CAST(json_extract(json_parse(`fields`), '$.customfield_10100') AS ARRAY(JSON))) AS t(`elem`) GROUP BY `id`")
340340
})
341+
it('should support double quoted table mentions', () => {
342+
const sql = `SELECT
343+
"my_table"."my_column"
344+
FROM
345+
"my_table"`
346+
expect(getParsedSql(sql)).to.be.equal('SELECT `my_table`.`my_column` FROM `my_table`')
347+
})
341348
})

test/transactsql.spec.js

+7
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,13 @@ describe('transactsql', () => {
389389
'SELECT [a].[username] AS [姓名] FROM [users] AS [a]'
390390
]
391391
},
392+
{
393+
title: 'double quoted table mentions',
394+
sql: [
395+
'SELECT a.username FROM "users" a',
396+
'SELECT [a].[username] FROM [users] AS [a]'
397+
]
398+
},
392399
]
393400
SQL_LIST.forEach(sqlInfo => {
394401
const { title, sql } = sqlInfo

0 commit comments

Comments
 (0)