clickhouse-java icon indicating copy to clipboard operation
clickhouse-java copied to clipboard

Code: 452. Setting max_execution_time should not be changed

Open oleg-agapov opened this issue 4 years ago • 3 comments

I'm trying to read Altinity demo server with Apache Spark using package ru.yandex.clickhouse:clickhouse-jdbc:0.3.1-patch and corresponding driver ru.yandex.clickhouse.ClickHouseDriver.

And I'm getting error:

Py4JJavaError: An error occurred while calling o41.load.
: ru.yandex.clickhouse.except.ClickHouseException: ClickHouse exception, code: 452, host: github.demo.trial.altinity.cloud, port: 8443; Code: 452, e.displayText() = DB::Exception: Setting max_execution_time should not be changed (version 21.3.15.4 (official build))

which obviously tells me that I'm trying to send max_execution_time property while it is being readonly.

The question is, can I pass some JDBC parameter or setting to overwrite this behavior and not send the parameter?

Here is my full program listing in PySpark:

from pyspark.sql import SparkSession

spark = (
    SparkSession.builder
    .config('spark.jars.packages', 'ru.yandex.clickhouse:clickhouse-jdbc:0.3.1-patch')
    .getOrCreate()
)

df = (
    spark.read
    .format("jdbc")
    .options(
        url="jdbc:clickhouse://github.demo.trial.altinity.cloud:8443/default",
        ssl=True,
        driver="ru.yandex.clickhouse.ClickHouseDriver",
        user="demo",
        password="demo",
        dbtable="airports"
    )
    .load()
)

oleg-agapov avatar Sep 11 '21 12:09 oleg-agapov

The question is, can I pass some JDBC parameter or setting to overwrite this behavior and bot send the parameter?

Spark set a default timeout which triggered the driver sending out max_execution_time to server. Why not simply start a click server using docker for testing? https://github.com/ClickHouse/clickhouse-jdbc/blob/5e6f74b89354e60af7d0c9437eef0520ee9ffda1/clickhouse-jdbc/src/main/java/ru/yandex/clickhouse/ClickHouseStatementImpl.java#L957-L959

This reminds me that maybe we need an option to discard all query parameters(with warnings in log?), because of scenario like this and proxy in the middle can set/overwrite query parameters as well.

zhicwu avatar Sep 11 '21 22:09 zhicwu

Ok, thank you, that's what I thought.

Implementing a way to overwrite those default parameters would be ideal (because I spotted only one edge case, but there might be others).

oleg-agapov avatar Sep 12 '21 13:09 oleg-agapov

Starting from 0.3.2-patch10, the driver has been slightly enhanced to respect server-side readonly setting. I was able to use DBeaver/SQuirreLSQL to connect to jdbc:ch://(https://[email protected]:443),(https://demo:[email protected])?load_balancing_policy=random(use arbitrary username and password) without any issue. We may still need an option to completely disable client-side setting.

zhicwu avatar Jul 05 '22 11:07 zhicwu

Starting from 0.4.2, JDBC driver will use centralized configuration(usually good defaults for a group of users) defined in custom server setting custom_jdbc_config.

zhicwu avatar Mar 18 '23 23:03 zhicwu