Skip to content

Commit 70be454

Browse files
authored
Merge pull request #2435 from ClickHouse/fix_keyword_as_alias
[jdbc-v2] Adds `source` keyword as one for alias
2 parents 5f377c4 + 1652400 commit 70be454

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

jdbc-v2/src/main/antlr4/com/clickhouse/jdbc/internal/ClickHouseParser.g4

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,16 @@ keywordForAlias
975975
| FIRST
976976
| ID
977977
| KEY
978+
| SOURCE
979+
| AFTER
980+
| CASE
981+
| CLUSTER
982+
| CURRENT
983+
| INDEX
984+
| TABLES
985+
| TEST
986+
| VIEW
987+
| PRIMARY
978988
;
979989

980990
alias

jdbc-v2/src/test/java/com/clickhouse/jdbc/PreparedStatementTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ void testBatchInsertWithRowBinary(String sql, Class implClass) throws Exception
768768

769769
int[] result = stmt.executeBatch();
770770
for (int r : result) {
771-
Assert.assertEquals(r, 1);
771+
Assert.assertTrue(r == 1 || r == PreparedStatement.SUCCESS_NO_INFO);
772772
}
773773
}
774774

jdbc-v2/src/test/java/com/clickhouse/jdbc/internal/SqlParserTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
package com.clickhouse.jdbc.internal;
22

33

4+
import org.antlr.v4.runtime.tree.TerminalNode;
45
import org.testng.Assert;
56
import org.testng.annotations.DataProvider;
67
import org.testng.annotations.Test;
78

9+
import java.lang.reflect.Method;
10+
import java.util.ArrayList;
11+
import java.util.Arrays;
12+
import java.util.List;
13+
814
import static org.testng.Assert.assertEquals;
915
import static org.testng.Assert.assertFalse;
1016
import static org.testng.Assert.assertTrue;
@@ -275,6 +281,18 @@ public Object[][] testMiscStmtDp() {
275281
return new Object[][] {
276282
{"SELECT INTERVAL '1 day'", 0},
277283
{"SELECT INTERVAL 1 day", 0},
284+
{"SELECT * FROM table key WHERE ts = ?", 1},
285+
{"SELECT * FROM table source WHERE ts = ?", 1},
286+
{"SELECT * FROM table after WHERE ts = ?", 1},
287+
{"SELECT * FROM table before WHERE ts = ?", 1},
288+
{"SELECT * FROM table case WHERE ts = ?", 1},
289+
{"SELECT * FROM table cluster WHERE ts = ?", 1},
290+
{"SELECT * FROM table current WHERE ts = ?", 1},
291+
{"SELECT * FROM table index WHERE ts = ?", 1},
292+
{"SELECT * FROM table tables WHERE ts = ?", 1},
293+
{"SELECT * FROM table test WHERE ts = ?", 1},
294+
{"SELECT * FROM table view WHERE ts = ?", 1},
295+
{"SELECT * FROM table primary WHERE ts = ?", 1},
278296
};
279297
}
280298
}

0 commit comments

Comments
 (0)