Please explain how this query generates a calendar table in MySQL
I don't know what you want in the explanation, but the last part of the query does a cross join (Cartesian join) to generate an ordered sequence of numbers from 0 to 11322 using the digits table named ints. The query then adds these number to date '2010-01-01' as day interval, thus generating

'2010-01-01'
'2010-01-02'
'2010-01-03'
.....
.....
'2040-12-31'


etc. till you add 11322 days, that is '2040-12-31'. These dates are then inserted into the dt field of the calendar_table.

Well this is a common way of creating a date dimension table. Once the dates are inserted you can update rest of the fields. You generally want to create your organization's holiday table and a payday logic or payday table to update the holiday and payday fields. Rest of the fields can be updated with a query with date functions as below.

update calendar_table
set y = year(dt),
q = quarter(dt),
m = month(dt),
d = day(dt),
dw = dayofweek(dt),
monthName = monthname(dt),
dayName = dayname(dt),
w = week(dt),
isWeekday=
case  
   when dayofweek(dt) = 1 or dayofweek(dt) = 7 then 0
   else 1
end;


Cheers.