kwilt commented on PR #38227:
URL: https://github.com/apache/superset/pull/38227#issuecomment-4651124657

   Thanks, this PR fixed some of the 422 errors I was experiencing but 
ultimately didn't resolve them all. I looked at my error logs to discover that 
Celery and Superset were still generating divergent hashes. I added some 
logging to find what appeared to be an AST tanspilation conflict causing the 
divergent hashes. I wrote the logged SQL expressions out to a couple of files 
and diffed them (see code block below). `superset.json` (top) was the 
sqlExpression from Superset and `celery.json` (bottom) was the sqlExpression 
from Celery, both from the same query/chart.
   
   ```
   diff superset.json celery.json
   
   62c62
   
   <         "sqlExpression": 
"cast(sum(casewhencurrent_workflow_placein('ordered')thenquote_priceelse0end)asdecimal(10,2))/sum(casewhennotquote_idisnullthenquote_priceelsenullend)"
   
   ---
   
   >         "sqlExpression": 
"sum(casewhencurrent_workflow_placein('ordered')thenquote_priceelse0end)::numeric(10,2)/sum(casewhenquote_idisnotnullthenquote_priceelsenullend)"
 
   
   ```
   
   So, what I believe is happening is Celery generates the hash after the SQL 
has already been transpiled, but Superset was not doing this - and this was 
leading to the hashes not matching, and subsequently, the 422 errors. Perhaps 
there is a bug somewhere else in the codebase that is causing this, but I took 
your PR and modified it perform the AST transpilation for every cache key being 
generated, stripped all the whitespace, and converted the text to lowercase, 
then my 422 errors went away completely.
   
   My patch on your PR: 
https://github.com/apache/superset/commit/689ead3940f0c4cb0ea884b2bdb5a4e08dbfec68
 (I'm not allowed to make edits to your own PR since you have disabled it)


-- 
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