-
Notifications
You must be signed in to change notification settings - Fork 614
Closed
Labels
Milestone
Description
Description
@chernser: The real problem is in statements like:
SELECT [...] FROM some_database.some_table source
WHERE source.some_column = ? AND source.some_other_column = ?
We need to make sure that short form of alias do not break parameter detection.
-- original description
The JDBC-V2 parser doesn't seem to correctly parse statements where there are aliases that happen to be keywords. The examples below illustrate this issue.
Steps to reproduce
- Using
sourceas an alias fails:PreparedStatement stmt = conn.prepareStatement("SELECT date, ? FROM system.one source WHERE ? = ?"); conn.getParameterMetadata().getParameterCount(); // returns 1 instead of 3
- Prepending
ASbefore the alias fixes the issue:PreparedStatement stmt = conn.prepareStatement("SELECT date, ? FROM system.one AS source WHERE ? = ?"); conn.getParameterMetadata().getParameterCount(); // returns 3 as expected
- Using a different alias also fixes the issue:
PreparedStatement stmt = conn.prepareStatement("SELECT date, ? FROM system.one _source WHERE ? = ?"); conn.getParameterMetadata().getParameterCount(); // returns 3 as expected
Expected Behaviour
The example query without the AS before the alias should work as well, as it's valid ClickHouse syntax.
Code Example
see repro steps above
Environment
Running integration tests on v0.8.6