Skip to content

Can't use JSON Formatter #188

Closed
Closed

Description

@dubcan

Query:

SELECT 1 FORMAT JSON

Expected 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)

Activity

  1. serebrserg commented on Mar 20, 2018

    @serebrserg
    Contributor

    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.

  2. dubcan commented on Mar 21, 2018

    @dubcan
    Author

    Sorry, I'm totally messed up with correct way of library usage. My bad. You are correct 100%

  3. added
    data-types
    jdbc
    legacy
    on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    data-typesjdbclegacyquestion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions