RubingHan commented on issue #25786:
URL: https://github.com/apache/superset/issues/25786#issuecomment-1817735730

   This error is due to a change in the logic of saving Datasets in Sqlab as of 
v3.0.1: in v2.1, this was handled separately within the `sqlab_viz` function in 
`views/core.py`, where templateParams were filled in before passing to the 
database; whereas in v3.0.1, it is consolidated into the 
`CreateDatasetCommand.run` function in `datasets/commands/create.py`, and the 
templateParams parameter was not passed along with the SQL to this function.
   
   It is uncertain whether this counts as a BUG since templateParams are indeed 
not necessary to be passed to the database during the Dataset creation process.
   
   In fact, there is a way to avoid triggering this error: by adding if 
expressions to these variables, ensuring that the variable expressions are not 
passed to the database when saving the Dataset. For example, a variable like 
`ds >= {{ to_dttm }}` can be modified to:
   ```
   <% if to_dttm %>
   ds >= {{ to_dttm }}
   <% endif %>
   ```
   This way, even in the absence of templateParams, the Dataset can still be 
saved and executed correctly. An `<% else %>` statement can also be added to 
define a default value for when the templateParams are missing.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to