Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spark datefram insert into clickhouse table, can't truncate #394

Open
PromiseNev opened this issue Dec 23, 2021 · 0 comments
Open

spark datefram insert into clickhouse table, can't truncate #394

PromiseNev opened this issue Dec 23, 2021 · 0 comments

Comments

@PromiseNev
Copy link

Environment

  • OS version: CentOS Linux release 7.9.2009 (Core)
  • JDK version: 1.8.0_312
  • ClickHouse Server version: 21.12.2.17
  • ClickHouse Native JDBC version: 2.6.4
  • (Optional) Spark version: 3.1.2

Error logs

21/12/23 06:26:40 INFO Client: 
	 client token: N/A
	 diagnostics: User class threw exception: java.sql.SQLException: Attempt to read after eof.
	at com.github.housepower.client.NativeClient.receiveResponse(NativeClient.java:183)
	at com.github.housepower.client.NativeClient.receiveHello(NativeClient.java:124)
	at com.github.housepower.jdbc.ClickHouseConnection.serverContext(ClickHouseConnection.java:325)
	at com.github.housepower.jdbc.ClickHouseConnection.createNativeContext(ClickHouseConnection.java:309)
	at com.github.housepower.jdbc.ClickHouseConnection.createClickHouseConnection(ClickHouseConnection.java:304)
	at com.github.housepower.jdbc.ClickHouseDriver.connect(ClickHouseDriver.java:58)
	at com.github.housepower.jdbc.ClickHouseDriver.connect(ClickHouseDriver.java:51)
	at com.github.housepower.jdbc.ClickHouseDriver.connect(ClickHouseDriver.java:26)
	at org.apache.spark.sql.execution.datasources.jdbc.connection.BasicConnectionProvider.getConnection(BasicConnectionProvider.scala:49)
	at org.apache.spark.sql.execution.datasources.jdbc.connection.ConnectionProvider$.create(ConnectionProvider.scala:68)
	at org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$.$anonfun$createConnectionFactory$1(JdbcUtils.scala:62)
	at org.apache.spark.sql.execution.datasources.jdbc.JdbcRelationProvider.createRelation(JdbcRelationProvider.scala:48)
	at org.apache.spark.sql.execution.datasources.SaveIntoDataSourceCommand.run(SaveIntoDataSourceCommand.scala:46)
	at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult$lzycompute(commands.scala:70)
	at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult(commands.scala:68)
	at org.apache.spark.sql.execution.command.ExecutedCommandExec.doExecute(commands.scala:90)
	at org.apache.spark.sql.execution.SparkPlan.$anonfun$execute$1(SparkPlan.scala:194)
	at org.apache.spark.sql.execution.SparkPlan.$anonfun$executeQuery$1(SparkPlan.scala:232)
	at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
	at org.apache.spark.sql.execution.SparkPlan.executeQuery(SparkPlan.scala:229)
	at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:190)
	at org.apache.spark.sql.execution.QueryExecution.toRdd$lzycompute(QueryExecution.scala:134)
	at org.apache.spark.sql.execution.QueryExecution.toRdd(QueryExecution.scala:133)
	at org.apache.spark.sql.DataFrameWriter.$anonfun$runCommand$1(DataFrameWriter.scala:989)
	at org.apache.spark.sql.catalyst.QueryPlanningTracker$.withTracker(QueryPlanningTracker.scala:107)
	at org.apache.spark.sql.execution.SQLExecution$.withTracker(SQLExecution.scala:232)
	at org.apache.spark.sql.execution.SQLExecution$.executeQuery$1(SQLExecution.scala:110)
	at org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$6(SQLExecution.scala:135)
	at org.apache.spark.sql.catalyst.QueryPlanningTracker$.withTracker(QueryPlanningTracker.scala:107)
	at org.apache.spark.sql.execution.SQLExecution$.withTracker(SQLExecution.scala:232)
	at org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$5(SQLExecution.scala:135)
	at org.apache.spark.sql.execution.SQLExecution$.withSQLConfPropagated(SQLExecution.scala:253)
	at org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$1(SQLExecution.scala:134)
	at org.apache.spark.sql.SparkSession.withActive(SparkSession.scala:775)
	at org.apache.spark.sql.execution.SQLExecution$.withNewExecutionId(SQLExecution.scala:68)
	at org.apache.spark.sql.DataFrameWriter.runCommand(DataFrameWriter.scala:989)
	at org.apache.spark.sql.DataFrameWriter.saveToV1Source(DataFrameWriter.scala:438)
	at org.apache.spark.sql.DataFrameWriter.saveInternal(DataFrameWriter.scala:415)
	at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:301)
	at com.metax.analysis.tmp.US_StockDataTranClickhouse$.main(US_StockDataTranClickhouse.scala:120)
	at com.metax.analysis.tmp.US_StockDataTranClickhouse.main(US_StockDataTranClickhouse.scala)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.spark.deploy.yarn.ApplicationMaster$$anon$2.run(ApplicationMaster.scala:735)

Steps to reproduce

  JdbcDialects.registerDialect(ClickHouseDialect)
    spark.sql("sql")
      .write
      .format("jdbc")
      .option("driver", ck_driver)
      .option("url", ck_url)
      .option("dbtable", "table")
      .option("user", ck_user)
      .option("password", ck_passwd)
      .option("truncate", "true")
      .option("batchsize", 100000)
      .option("isolationLevel", "NONE")
      .mode(SaveMode.Overwrite)
      .save()

Other descriptions

insert into clickhouse table, can't truncate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant