Repository navigation
Closed
Labels
data-typesArea: type names, value encoding and decoding, row mapping, data formatsjdbcModule: the JDBC driver (jdbc-v2; with legacy: the v1 driver)legacyOnly the v1 stack (clickhouse-client, clickhouse-http-client, clickhouse-jdbc) has the problemquestion
Description
Query:
SELECT 1 FORMAT JSONExpected response:
{
"meta":
[
{
"name": "1",
"type": "UInt8"
}
],
"data":
[
{
"1": 1
}
],
"rows": 1,
"statistics":
{
"elapsed": 0.000030789,
"rows_read": 1,
"bytes_read": 1
}
}Result:
ru.yandex.clickhouse.except.ClickHouseException: ClickHouse exception, code: 62, host: localhost, port: 8123; Code: 62, e.displayText() = DB::Exception: Syntax error: failed at position 17: JSON FORMAT TabSeparatedWithNamesAndTypes;. Expected identifier, e.what() = DB::Exception
at ru.yandex.clickhouse.except.ClickHouseExceptionSpecifier.specify(ClickHouseExceptionSpecifier.java:58)
at ru.yandex.clickhouse.except.ClickHouseExceptionSpecifier.specify(ClickHouseExceptionSpecifier.java:28)
at ru.yandex.clickhouse.ClickHouseStatementImpl.getInputStream(ClickHouseStatementImpl.java:526)
at ru.yandex.clickhouse.ClickHouseStatementImpl.executeQuery(ClickHouseStatementImpl.java:105)
at ru.yandex.clickhouse.ClickHouseStatementImpl.executeQuery(ClickHouseStatementImpl.java:89)
at ru.yandex.clickhouse.ClickHouseStatementImpl.executeQuery(ClickHouseStatementImpl.java:85)
at ru.yandex.clickhouse.ClickHouseStatementImpl.execute(ClickHouseStatementImpl.java:165)
Metadata
Metadata
Assignees
Labels
data-typesArea: type names, value encoding and decoding, row mapping, data formatsjdbcModule: the JDBC driver (jdbc-v2; with legacy: the v1 driver)legacyOnly the v1 stack (clickhouse-client, clickhouse-http-client, clickhouse-jdbc) has the problemquestion
Activity
serebrserg commentedon Mar 20, 2018
I propose to discuss both this and #189 issues here.
I don't think one should add a FORMAT at all when executing query through JDBC interface.
In current implementation the driver adds FORMAT TabSeparatedWithNamesAndTypes while executing query and expects answer in this format to correctly parse it and make the answer be available through JDBC interface, i.e. ResultSet and ResultSetMetadata. The types are parsed, the values are separated, parsed and are available through typed getters like getInt(), getString() and getObject().
I don't understand how do you want to use the result in JSON or JSONCompact format though JDBC interface.
If I have missed something, please add a code sample and more detailed description of what you want to execute.
dubcan commentedon Mar 21, 2018
Sorry, I'm totally messed up with correct way of library usage. My bad. You are correct 100%