superset icon indicating copy to clipboard operation
superset copied to clipboard

Adding New Column to Table - "no such column" error

Open csc5k opened this issue 9 years ago • 3 comments

Make sure these boxes are checked before submitting your issue - thank you!

  • [x ] I have checked the superset logs for python stacktraces and included it here as text if any
  • [x ] I have reproduced the issue with at least the latest released version of superset
  • [x ] I have checked the issue tracker for the same issue and I haven't found one similar

I am trying to add a column to my table that calculates the running total of another column. I followed the instructions listed on the FAQ for adding a new column to a table, but I receive the error pasted below

Superset version

0.20.4

Expected results

My table has a column that contains the cumulative sum of another column

Actual results

I receive this error:

(sqlite3.OperationalError) no such column: encounter.sum_penta1 [SQL: 'SELECT CAST((SUM(encounter.sum_penta1) - SUM(encounter.pentavalent_dose_3)) as float) / CAST(SUM(encounter.pentavalent_dose_1) as float) AS "Penta 1 to Penta 3 Dropout",\n CAST((SUM(encounter.pentavalent_dose_1) - SUM(encounter.measles_mr_dose_1)) as float) / CAST(SUM(encounter.pentavalent_dose_1) as float) AS "Penta 1 to Measles Dropout",\n SUM(encounter.pentavalent_dose_1) AS sum__pentavalent_dose_1,\n SUM(encounter.pentavalent_dose_3) AS sum__pentavalent_dose_3,\n SUM(encounter.measles_mr_dose_1) AS sum__measles_mr_dose_1\nFROM encounter\nWHERE encounter_date >= '2017-06-08 00:00:00.000000'\n AND encounter_date <= '2017-06-10 00:00:00.000000'\nORDER BY sum__pentavalent_dose_1 DESC\nLIMIT 50000\nOFFSET 0']

Steps to reproduce

run any query in a slice that contains a metric that includes my new column

csc5k avatar Nov 02 '17 09:11 csc5k

sqlite3 thinks otherwise :) Anyway what you are missing is that adding a column in superset tells superset you already have that column in the db, it does not add it to the database.

xrmx avatar Nov 02 '17 09:11 xrmx

I followed the steps listed in your FAQ on how to add a new column, but it is not getting added

csc5k avatar Nov 02 '17 09:11 csc5k

Note that your SQL expression (let's call that a virtual column) can only reference physical columns in the table, not other Superset virtual columns

mistercrunch avatar Nov 04 '17 07:11 mistercrunch