I started to try and replicate your error, but honestly, it became a bit too much work. The report is referencing a table, "sequence", that must be a custom table? If you create a custom table, I would encourage you to put it in a custom schema.
I looked at the report and the first thought I had was, "I would simplify this". You have a query source of "detail" and one of "D2", but only a single section. I don't think you need both of them. Because you're using the metasql, I would copy the metasql and modify it to meet your needs and include the values that are coming from D2.