stockarea commented on issue #37551:
URL: https://github.com/apache/superset/issues/37551#issuecomment-3818706791

   2026-01-29 16:13:44,607:WARNING:superset.connectors.sqla.models:Query SELECT 
sortable_month_year AS sortable_month_year 
   FROM (SELECT
     c.document_number AS contract_document_number,
     cs.id AS contract_service_id,
     cs.month,
     cs.year,
     CONCAT(cs.year, ' ', cs.month) AS monthly_time,
     DATE_FORMAT(STR_TO_DATE(CONCAT(cs.month, ' 1, ', cs.year), '%M %d, %Y'), 
'%Y-%m') AS sortable_month_year,
     cs.category,
     cg.status AS group_status,
     cg.name AS group_name,
     c.type AS contract_type,
     w.code AS warehouse_code,
     cities.name AS city_name,
     CASE
       WHEN cs.operation = 'sum'
       THEN SUM(cse.transaction)
       WHEN cs.operation = 'max'
       THEN MAX(SUM(cse.transaction)) OVER (PARTITION BY cs.id, 
cse.transaction_date)
       WHEN cs.operation = 'min'
       THEN MIN(SUM(cse.transaction)) OVER (PARTITION BY cs.id, 
cse.transaction_date)
       ELSE 0
     END AS total_transaction,
     cs.price AS price_per_unit,
     cs.operation,
     cs.prorata
   FROM contract_groups AS cg
   LEFT JOIN (
     SELECT
       *
     FROM contract
     WHERE
       (
         contract_document_number IN (
           1,
           2,
           3,
           4,
           5,
           6,
           7,
           8,
           9,
           10,
           11
         )
       )
   ) AS c
     ON c.group_id = cg.id
   LEFT JOIN contract_services AS cs
     ON c.id = cs.contract_id AND cs.deleted_at IS NULL
   LEFT JOIN contract_service_executions AS cse
     ON cs.id = cse.contract_service_id
   LEFT JOIN warehouses AS w
     ON cg.warehouse_id = w.id
   LEFT JOIN (
     SELECT
       *
     FROM cities
     WHERE
       (
         contract_document_number IN (
           1,
           2,
           3,
           4,
           5,
           6,
           7,
           8,
           9,
           10,
           11
         )
       )
   ) AS `cities`
     ON w.cities_id = cities.id
   WHERE
     cg.status = 'active'
     AND STR_TO_DATE(CONCAT(cs.month, ' 1, ', cs.year), '%M %d, %Y') BETWEEN 
DATE_SUB(DATE_FORMAT(CURRENT_DATE, '%Y-%m-01'), INTERVAL '6' MONTH) AND 
LAST_DAY(DATE_SUB(CURRENT_DATE, INTERVAL '1' MONTH))
   GROUP BY
     c.id,
     cs.month,
     cs.year,
     cs.id,
     cs.operation,
     cs.category,
     price_per_unit,
     cs.prorata,
     cg.id
   ORDER BY
     contract_service_id DESC) AS virtual_table 
   WHERE (contract_document_number In (1,2,3,4,5,6,7,8,9,10,11)) GROUP BY 
sortable_month_year ORDER BY sortable_month_year DESC 
    LIMIT 1000 on schema stockarea_dw failed
   Traceback (most recent call last):
     File "/app/superset/connectors/sqla/models.py", line 1652, in query
       df = self.database.get_df(
     File "/app/superset/models/core.py", line 709, in get_df
       self.db_engine_spec.execute(cursor, sql_, self)
     File "/app/superset/db_engine_specs/base.py", line 1855, in execute
       raise cls.get_dbapi_mapped_exception(ex) from ex
     File "/app/superset/db_engine_specs/base.py", line 1851, in execute
       cursor.execute(query)
     File "/app/.venv/lib/python3.10/site-packages/MySQLdb/cursors.py", line 
179, in execute
       res = self._query(mogrified_query)
     File "/app/.venv/lib/python3.10/site-packages/MySQLdb/cursors.py", line 
330, in _query
       db.query(q)
     File "/app/.venv/lib/python3.10/site-packages/MySQLdb/connections.py", 
line 265, in query
       _mysql.connection.query(self, query)
   MySQLdb.OperationalError: (1054, "Unknown column 'contract_document_number' 
in 'where clause'")
   
   
   
   I have got the query and here is error.
   
   Why it is trying to have contract_document_number in between the query? It 
should only apply at the end right??
   


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