mirror of
https://github.com/apache/druid.git
synced 2025-02-25 04:16:07 +00:00
fix ingest datasource detection falling over on paren (#15339)
This commit is contained in:
parent
130bfbfc6d
commit
d12f557492
@ -487,6 +487,18 @@ describe('WorkbenchQuery', () => {
|
||||
expect(workbenchQuery.changeEngine('sql-native').getIngestDatasource()).toBeUndefined();
|
||||
});
|
||||
|
||||
it('works with INSERT (unparsable with paren)', () => {
|
||||
const sql = sane`
|
||||
-- Some comment
|
||||
INSERT into trips2
|
||||
(SELECT TIME_PARSE(pickup_datetime) AS __time,
|
||||
`;
|
||||
|
||||
const workbenchQuery = WorkbenchQuery.blank().changeQueryString(sql);
|
||||
expect(workbenchQuery.getIngestDatasource()).toEqual('trips2');
|
||||
expect(workbenchQuery.changeEngine('sql-native').getIngestDatasource()).toBeUndefined();
|
||||
});
|
||||
|
||||
it('works with REPLACE', () => {
|
||||
const sql = sane`
|
||||
REPLACE INTO trips2 OVERWRITE ALL
|
||||
|
@ -226,7 +226,7 @@ export class WorkbenchQuery {
|
||||
|
||||
const queryStartingWithInsertOrReplace = queryFragment.substring(matchInsertReplaceIndex);
|
||||
|
||||
const matchEnd = queryStartingWithInsertOrReplace.match(/\b(?:SELECT|WITH)\b|$/i);
|
||||
const matchEnd = queryStartingWithInsertOrReplace.match(/\(|\b(?:SELECT|WITH)\b|$/i);
|
||||
const fragmentQuery = SqlQuery.maybeParse(
|
||||
queryStartingWithInsertOrReplace.substring(0, matchEnd?.index) + ' SELECT * FROM t',
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user