Skip to content

Error after calling getPrimaryKeys for the older database version #2654

@Destrolaric

Description

@Destrolaric

Description

New driver versions now can't call the getPrimaryKeys function due to not having a valid SQL syntax for the older version.
The issue is not reproducible for the newer database version
This might be a regression - driver version 0.8.5 doesn't have the mentioned problem

Steps to reproduce

  1. Call getPrimaryKeys for an old database version

Error Log or Exception StackTrace

SQL Error [22000]: Code: 62. DB::Exception: Syntax error: failed at position 147 ('::'): ::Int16 AS KEY_SEQ, 'PRIMARY' AS PK_NAME FROM system.tables ARRAY JOIN arrayZip(splitByChar(',', primary_key), arrayEnumerate(splitByChar(',', primary_key))) as. Expected one of: MOD, DIV, NOT, BETWEEN, LIKE, ILIKE, NOT LIKE, NOT ILIKE, IN, NOT IN, GLOBAL IN, GLOBAL NOT IN, IS, AND, OR, token, QuestionMark, alias, AS, identifier, Comma, FROM, PREWHERE, WHERE, GROUP BY, WITH, HAVING, WINDOW, ORDER BY, LIMIT, OFFSET, SETTINGS, UNION, EXCEPT, INTERSECT, INTO OUTFILE, FORMAT, end of query. (SYNTAX_ERROR) (version 22.1.3.7 (official build)) 
com.clickhouse.client.api.ServerException: Code: 62. DB::Exception: Syntax error: failed at position 147 ('::'): ::Int16 AS KEY_SEQ, 'PRIMARY' AS PK_NAME FROM system.tables ARRAY JOIN arrayZip(splitByChar(',', primary_key), arrayEnumerate(splitByChar(',', primary_key))) as. Expected one of: MOD, DIV, NOT, BETWEEN, LIKE, ILIKE, NOT LIKE, NOT ILIKE, IN, NOT IN, GLOBAL IN, GLOBAL NOT IN, IS, AND, OR, token, QuestionMark, alias, AS, identifier, Comma, FROM, PREWHERE, WHERE, GROUP BY, WITH, HAVING, WINDOW, ORDER BY, LIMIT, OFFSET, SETTINGS, UNION, EXCEPT, INTERSECT, INTO OUTFILE, FORMAT, end of query. (SYNTAX_ERROR) (version 22.1.3.7 (official build)) 
	at com.clickhouse.client.api.internal.HttpAPIClientHelper.readError(HttpAPIClientHelper.java:398)
	at com.clickhouse.client.api.internal.HttpAPIClientHelper.executeRequest(HttpAPIClientHelper.java:461)
	at com.clickhouse.client.api.Client.lambda$query$5(Client.java:1599)
	at com.clickhouse.client.api.Client.runAsyncOperation(Client.java:2014)
	at com.clickhouse.client.api.Client.query(Client.java:1644)
	at com.clickhouse.client.api.Client.query(Client.java:1542)
	at com.clickhouse.jdbc.StatementImpl.executeQueryImpl(StatementImpl.java:158)
	at com.clickhouse.jdbc.StatementImpl.executeQuery(StatementImpl.java:113)
	at com.clickhouse.jdbc.metadata.DatabaseMetaDataImpl.getPrimaryKeys(DatabaseMetaDataImpl.java:998)
	at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCDatabaseMetaDataImpl.lambda$19(JDBCDatabaseMetaDataImpl.java:938)
	at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCDatabaseMetaDataImpl.makeResultSet(JDBCDatabaseMetaDataImpl.java:74)
	at org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCDatabaseMetaDataImpl.getPrimaryKeys(JDBCDatabaseMetaDataImpl.java:937)
	at org.jkiss.dbeaver.ext.generic.model.meta.GenericMetaModel.prepareUniqueConstraintsLoadStatement(GenericMetaModel.java:885)
	at org.jkiss.dbeaver.ext.generic.model.ConstraintKeysCache.prepareObjectsStatement(ConstraintKeysCache.java:61)
	at org.jkiss.dbeaver.ext.generic.model.ConstraintKeysCache.prepareObjectsStatement(ConstraintKeysCache.java:1)
	at org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCCompositeCache.loadObjects(JDBCCompositeCache.java:300)
	at org.jkiss.dbeaver.model.impl.jdbc.cache.JDBCCompositeCache.getObjects(JDBCCompositeCache.java:135)
	at org.jkiss.dbeaver.ext.generic.model.GenericTableBase.getConstraints(GenericTableBase.java:251)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.jkiss.dbeaver.model.navigator.DBNDatabaseNode.extractPropertyValue(DBNDatabaseNode.java:1041)
	at org.jkiss.dbeaver.model.navigator.DBNDatabaseNode$PropertyValueReader.run(DBNDatabaseNode.java:1113)
	at org.jkiss.dbeaver.model.navigator.DBNDatabaseNode$PropertyValueReader.run(DBNDatabaseNode.java:1)
	at org.jkiss.dbeaver.model.exec.DBExecUtils.tryExecuteRecover(DBExecUtils.java:189)
	at org.jkiss.dbeaver.model.navigator.DBNDatabaseNode.loadTreeItems(DBNDatabaseNode.java:654)
	at org.jkiss.dbeaver.model.navigator.DBNDatabaseNode.loadChildren(DBNDatabaseNode.java:467)
	at org.jkiss.dbeaver.model.navigator.DBNDatabaseNode.getChildren(DBNDatabaseNode.java:221)
	at org.jkiss.dbeaver.model.navigator.DBNDatabaseNode.getChildren(DBNDatabaseNode.java:1)
	at org.jkiss.dbeaver.model.navigator.DBNUtils.getNodeChildrenFiltered(DBNUtils.java:110)
	at io.cloudbeaver.service.navigator.impl.WebServiceNavigator.getNavigatorNodeChildren(WebServiceNavigator.java:105)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)

Table DDL


CREATE TABLE default.hits_NoPrimaryKey
(

    `UserID` UInt32,

    `URL` String,

    `EventTime` DateTime
)
ENGINE = MergeTree
PRIMARY KEY tuple()
ORDER BY tuple()
SETTINGS index_granularity = 8192;

Expected Behaviour

getPrimaryKeys should have the old behavior

Environment

  • Cloud
  • Client version: 0.9.4

ClickHouse Server

  • ClickHouse Server version: 22.1.3.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:jdbc-metadataissue handling metadata things like getting type of columnbugjdbc-v2jdbc-v2 issues

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions