Denis,

I can check it out soon. The mentioned problem can probably only be related to JDBC data frames. In this case, I will create a JIRA ticket. But as I know using OPTION_CREATE_TABLE_PRIMARY_KEY_FIELDS should be the same as I showed in my example.

BR,
Andrei

10/30/2020 6:01 PM, Denis Magda пишет:
Andrey,

Do we need to update our docs? It feels like the docs miss these details or have an outdated example.

-
Denis


On Fri, Oct 30, 2020 at 7:03 AM Andrei Aleksandrov <aealexsand...@gmail.com <mailto:aealexsand...@gmail.com>> wrote:

    Hi,

    Here's an example with correct syntax that should work fine:

    |DataFrameWriter < Row > df = resultDF .write()
    .format(IgniteDataFrameSettings.FORMAT_IGNITE())
    .option(IgniteDataFrameSettings.OPTION_CONFIG_FILE(), configPath)
    .option(IgniteDataFrameSettings.OPTION_TABLE(), "Person")
    .option(IgniteDataFrameSettings.OPTION_CREATE_TABLE_PRIMARY_KEY_FIELDS(),
    "id, city_id")
    .option(IgniteDataFrameSettings.OPTION_CREATE_TABLE_PARAMETERS(),
    "template=partitioned,backups=1") .mode(Append); |

    Please let me know if something is wrong here.

    BR,
    Andrei

    10/30/2020 2:20 AM, Humphrey пишет:
    Hello guys this question has been asked on  Stack Overflow
<https://stackoverflow.com/questions/64554684/how-to-create-a-table-with-primary-key-using-jdbc-spark-connector-to-ignite> <https://stackoverflow.com/questions/64554684/how-to-create-a-table-with-primary-key-using-jdbc-spark-connector-to-ignite> but yet no answer is a provided.

    I'm facing the same issue (trying to insert data in ignite using
    spark.jdbc):
    Exception in thread "main" java.sql.SQLException: No PRIMARY KEY defined for
    CREATE TABLE
        at
    
org.apache.ignite.internal.jdbc.thin.JdbcThinConnection.sendRequest(JdbcThinConnection.java:1004)

    Code:
         println("-- writing using jdbc --")
         val prop = Properties()
         prop["driver"] = "org.apache.ignite.IgniteJdbcThinDriver"

         df.write().apply {
                 mode(SaveMode.Overwrite)
                 format("jdbc")
                 option("url", "jdbc:ignite:thin://127.0.0.1  
<http://127.0.0.1>")
                 option("dbtable", "comments")
option(IgniteDataFrameSettings.OPTION_CREATE_TABLE_PRIMARY_KEY_FIELDS(),
    "last_name")
         }.save()

    The last option doesn't seem to work/help.



    --
    Sent from:http://apache-ignite-users.70518.x6.nabble.com/  
<http://apache-ignite-users.70518.x6.nabble.com/>

Reply via email to