2017-01-17 1 views
0

Citusを使用して作成したハッシュ分散テーブルにデータを挿入しようとしています。 Pysparkでは、JDBC postgresドライブを使用してテーブルにデータを挿入しています。私はpysparkでJDBCを使用してテーブルにデータを挿入するために使用しています コードは次のとおりです。PysparkでJDBCを使用してCitusハッシュ分散テーブルに挿入

: org.postgresql.util.PSQLException: ERROR: relation "table_name" already exists 
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2455) 
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2155) 
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:288) 
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:430) 
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:356) 
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:303) 
at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:289) 
at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:266) 
at org.postgresql.jdbc.PgStatement.executeUpdate(PgStatement.java:246) 
at org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$.createTable(JdbcUtils.scala:692) 
at org.apache.spark.sql.execution.datasources.jdbc.JdbcRelationProvider.createRelation(JdbcRelationProvider.scala:89) 
at org.apache.spark.sql.execution.datasources.DataSource.write(DataSource.scala:426) 
at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:215) 
at org.apache.spark.sql.DataFrameWriter.jdbc(DataFrameWriter.scala:446) 
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:497) 
at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244) 
at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357) 
at py4j.Gateway.invoke(Gateway.java:280) 
at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132) 
at py4j.commands.CallCommand.execute(CallCommand.java:79) 
at py4j.GatewayConnection.run(GatewayConnection.java:214) 
at java.lang.Thread.run(Thread.java:745) 

は、誰かが私はデータを挿入しますどのように私を助けてください。私はこのエラーを取得しています。この設定では

url = "jdbc:postgresql://host:port/db_name?rewriteBatchedStatements=true" 
    properties = {"user":"user_name","password":"password"} 
    df = spark.createDataFrame(rdd_name) 
    df.write.jdbc(url=url, table="table_name", mode="append", properties=properties) 

pysparkでjdbcを使ってcitrus postgresに入れますか?前もって感謝します。

+0

スパークバージョンは使用していますか? – Yaron

答えて

1

"table_name"が既に存在するというエラーメッセージが表示されます。おそらく、コードやフレームワークが同じテーブルを再度作成しようとしている可能性があります。それを確認できますか?

関連する問題