heavyai/pymapd

INSERT using f-string failing

realtonyyoung opened this issue · 1 comments

I have a customer trying to use pymapd to do a insert operation and it's failing with exception:

2019-09-18T15:30:10.497444 1 16 MapDHandler.cpp:784 stdlog_begin sql_execute 108 0 omnisci admin 009-mie5 {"query_str"} {"
        insert into Forecast_PGW_C_Subs_Hist
        VALUES ('08/31/2019',123,234,345,456.70001220703125,567,12345)
    "}
2019-09-18T15:30:10.497934 I 16 Calcite.cpp:455 User admin catalog omnisci sql '
        insert into Forecast_PGW_C_Subs_Hist
        VALUES ('08/31/2019',123,234,345,456.70001220703125,567,12345)
    '
2019-09-18T15:30:10.502526 E 16 MapDHandler.cpp:4967 Exception: Exception occurred: org.apache.calcite.runtime.CalciteContextException: From line 1, column 13 to line 1, column 38: Column 'rowid' has no default value and does not allow NULLs
2019-09-18T15:30:10.502668 I 16 MapDHandler.cpp:784 stdlog sql_execute 108 5 omnisci admin 009-mie5 {"query_str"} {"
        insert into Forecast_PGW_C_Subs_Hist
        VALUES ('08/31/2019',123,234,345,456.70001220703125,567,12345)
    "}
2019-09-18T15:30:10.611998 1 16 MapDHandler.cpp:395 stdlog_begin disconnect 109 0 omnisci admin 009-mie5  
2019-09-18T15:30:10.612052 I 16 MapDHandler.cpp:399 User admin disconnected from database omnisci

If I take the same INSERT code and run it through omnisql, it runs just fine. The piece of python code doing the insert is here:

    insertHist_i = f'''
        insert into Forecast_PGW_C_Subs_Hist
        VALUES (:dt,:histCap,:engCap,:lic,:engLimit,:histForecast,:actGrowth)
    '''

...

    # Copy last month from _Future to _Hist
    c.execute(insertHist_i,parameters={"dt":lastmo,"histCap":histCap,"engCap":engCap,"lic":lic,"engLimit":engLimit,"histForecast":histForecast,"actGrowth":subcnt})

Trimming the f-string fixes the issue. Affects pymapd 0.12.1 and 0.15.0

Thanks for the report @realtonyyoung. This error occurs here: https://github.com/omnisci/pymapd/blob/master/pymapd/cursor.py#L105

This bug should be fixed today and a new version of pymapd by the end of the week.