update sql parser name
This commit is contained in:
parent
0d47b7debc
commit
edbc87e8f1
@ -14,7 +14,7 @@
|
||||
* This file is an adaptation of Presto's presto-parser/src/main/antlr4/com/facebook/presto/sql/parser/SqlBase.g4 grammar.
|
||||
*/
|
||||
|
||||
grammar SqlBase;
|
||||
grammar SparkSql;
|
||||
|
||||
@parser::members {
|
||||
/**
|
File diff suppressed because it is too large
Load Diff
2445
src/lib/spark/SparkSqlListener.js
Normal file
2445
src/lib/spark/SparkSqlListener.js
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
1636
src/lib/spark/SparkSqlVisitor.js
Normal file
1636
src/lib/spark/SparkSqlVisitor.js
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,19 +1,19 @@
|
||||
import { InputStream, CommonTokenStream, Lexer } from 'antlr4';
|
||||
import { SqlBaseLexer } from '../lib/spark/SqlBaseLexer';
|
||||
import { SqlBaseParser } from '../lib/spark/SqlBaseParser';
|
||||
export * from '../lib/spark/SqlBaseVisitor';
|
||||
export * from '../lib/spark/SqlBaseListener';
|
||||
import { SparkSqlLexer } from '../lib/spark/SparkSqlLexer';
|
||||
import { SparkSqlParser } from '../lib/spark/SparkSqlParser';
|
||||
export * from '../lib/spark/SparkSqlVisitor';
|
||||
export * from '../lib/spark/SparkSqlListener';
|
||||
|
||||
import BasicParser from './common/BasicParser';
|
||||
|
||||
export default class SparkSQL extends BasicParser {
|
||||
public createLexer(input: string): Lexer {
|
||||
const chars = new InputStream(input.toUpperCase()); // Some Lexer only support uppercase token, So you need transform
|
||||
const lexer = <unknown> new SqlBaseLexer(chars) as Lexer;
|
||||
const lexer = <unknown> new SparkSqlLexer(chars) as Lexer;
|
||||
return lexer;
|
||||
}
|
||||
public createParserFromLexer(lexer: Lexer) {
|
||||
const tokenStream = new CommonTokenStream(lexer);
|
||||
return new SqlBaseParser(tokenStream);
|
||||
return new SparkSqlParser(tokenStream);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import SQLParser, { SqlBaseListener } from '../../../src/parser/spark';
|
||||
import SQLParser, { SparkSqlListener } from '../../../src/parser/spark';
|
||||
|
||||
describe('Spark SQL Listener Tests', () => {
|
||||
const expectTableName = 'user1';
|
||||
@ -9,7 +9,7 @@ describe('Spark SQL Listener Tests', () => {
|
||||
|
||||
test('Listener enterTableName', () => {
|
||||
let result = '';
|
||||
class MyListener extends SqlBaseListener {
|
||||
class MyListener extends SparkSqlListener {
|
||||
enterTableName(ctx): void {
|
||||
result = ctx.getText().toLowerCase();
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
/* eslint-disable max-len */
|
||||
import SQLParser from '../../../src/parser/spark';
|
||||
|
||||
// const log = console.log.bind(console);
|
||||
const error = console.log.bind(console, '***** error\n');
|
||||
|
||||
const validateTest = (sqls) => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import SQLParser, { SqlBaseVisitor } from '../../../src/parser/spark';
|
||||
import SQLParser, { SparkSqlVisitor } from '../../../src/parser/spark';
|
||||
|
||||
describe('Spark SQL Visitor Tests', () => {
|
||||
const expectTableName = 'user1';
|
||||
@ -13,7 +13,7 @@ describe('Spark SQL Visitor Tests', () => {
|
||||
|
||||
test('Visitor visitTableName', () => {
|
||||
let result = '';
|
||||
class MyVisitor extends SqlBaseVisitor {
|
||||
class MyVisitor extends SparkSqlVisitor {
|
||||
visitTableName(ctx): void {
|
||||
result = ctx.getText().toLowerCase();
|
||||
super.visitTableName(ctx);
|
||||
|
Loading…
Reference in New Issue
Block a user