You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when attempting to make a union select statement of a form similar to:
SELECT *
FROM test_table
UNION DISTINCT
SELECT *
FROM test_table
Steps to reproduce
make a prepared statement using the above query
executeQuery
Error Log or Exception StackTrace
line 1:31 mismatched input 'DISTINCT' expecting ALL
Expected Behaviour
a union of distinct elements is performed on the given select statements. (it looks like the antlr grammar specifically defines a union statement as 2 selects UNION ALL)
Code Example
Stringsql = "SELECT * FROM " + TABLE_NAME + " UNION DISTINCT SELECT * FROM " + TABLE_NAME;
// try to get all results with a union distinct try (PreparedStatementpstmt = connection.prepareStatement(sql)) {
try (Statementstmt = connection.createStatement();
ResultSetrs = stmt.executeQuery(sql)) {
while (rs.next()) {
System.out.println("id: " + rs.getInt("id") + ", Name: " + rs.getString("NameCol") + ", Attributes: " + rs.getString("MapCol") + ", TimeStamp: " + rs.getString("TimeCol") + ", Value: " + rs.getDouble("Value"));
}
}
}
Configuration
tested with a local docker container at clickhouse:8123
Environment
Client version: 0.9.0
Language version: Java 17.0.6
OS: CentOS 8 (also seen on Rocky9)
ClickHouse Server
ClickHouse Server version: 25.5.2
ClickHouse Server non-default settings, if any: N/A
CREATE TABLE statements for tables involved:
CREATE TABLE IF NOT EXISTS test_table (
id UInt64,
NameCol String,
MapCol Map(LowCardinality(String), String),
TimeCol TIMESTAMP,
Value Float
) ENGINE = MergeTree()
ORDER BY id
Activity