diff --git a/core/src/main/java/com/alibaba/druid/sql/parser/Lexer.java b/core/src/main/java/com/alibaba/druid/sql/parser/Lexer.java index 666e0e9648..3fbcfc2760 100644 --- a/core/src/main/java/com/alibaba/druid/sql/parser/Lexer.java +++ b/core/src/main/java/com/alibaba/druid/sql/parser/Lexer.java @@ -2662,12 +2662,21 @@ public void scanIdentifier() { mark = pos; bufPos = 1; char ch = 0; + boolean hasLeftBrace = false; for (; ; ) { char c0 = ch; ch = charAt(++pos); if (!isIdentifierChar(ch)) { - if ((ch == '(' || ch == ')') && c0 > 256) { + if (((ch == '(' || ch == ')') && c0 > 256) || ch == '$') { + bufPos++; + continue; + } else if (ch == '{' && c0 == '$') { + hasLeftBrace = true; + bufPos++; + continue; + } else if (ch == '}' && hasLeftBrace) { + hasLeftBrace = false; bufPos++; continue; } diff --git a/core/src/test/resources/bvt/parser/hive/1.txt b/core/src/test/resources/bvt/parser/hive/1.txt index 3571f19b29..8de86a8b57 100644 --- a/core/src/test/resources/bvt/parser/hive/1.txt +++ b/core/src/test/resources/bvt/parser/hive/1.txt @@ -67,4 +67,19 @@ WITH SERDEPROPERTIES ( ) TBLPROPERTIES ( 'hbase.table.name' = '11111' -) \ No newline at end of file +) +------------------------------------------------------------------------------------------------------------------------ +select * from ${template}.a +-------------------- +SELECT * +FROM ${template}.a +------------------------------------------------------------------------------------------------------------------------ +select * from ${template}.ab${suffix} +-------------------- +SELECT * +FROM ${template}.ab${suffix} +------------------------------------------------------------------------------------------------------------------------ +select * from cd${template}.ab${suffix} +-------------------- +SELECT * +FROM cd${template}.ab${suffix} \ No newline at end of file