gulldan commented on issue #31674:
URL: https://github.com/apache/superset/issues/31674#issuecomment-2590111568

   ```
   WITH
       subA AS
       (
           SELECT
               tA.col1 AS cluster_id,
               tA.col2 AS social_field,
               max(tB.col3) AS Ner,
               tA.col4 AS some_date
           FROM TableA AS tA
           INNER JOIN TableB AS tB
               ON arrayJoin(tA.col2) = tB.UUID
           GROUP BY
               tA.col1, tA.col2, tA.col4
       ),
   
       subB AS
       (
           SELECT
               tC.col1 AS cluster_id,
               tC.col5 AS smi_field,
               length(tC.col5) AS smi_count,
               min(tD.col6) AS min_created,
               argMin(tD.col7, tD.col6) AS some_title,
               max(tD.col3) AS Ner
           FROM TableC AS tC
           INNER JOIN TableD AS tD
               ON arrayJoin(tC.col5) = tD.UUID
           GROUP BY
               tC.col1, tC.col5
       ),
   
       grouped_ners AS
       (
           SELECT
               cluster_id,
               ner,
               sum(value_count) AS value_count
           FROM
           (
               SELECT
                   cluster_id,
                   arrayJoin(mapValues(Ner)) AS ner,
                   count() AS value_count
               FROM subB
               GROUP BY cluster_id, ner
               UNION ALL
               SELECT
                   cluster_id,
                   arrayJoin(mapValues(Ner)) AS ner,
                   count() AS value_count
               FROM subA
               GROUP BY cluster_id, ner
           )
           GROUP BY cluster_id, ner
       ),
   
       total_ners AS
       (
           SELECT
               cluster_id,
               count() AS total
           FROM grouped_ners
           GROUP BY cluster_id
       ),
   
       filtered_ners AS
       (
           SELECT
               gn.cluster_id,
               groupArrayArray(gn.ner) AS ners
           FROM grouped_ners AS gn
           INNER JOIN total_ners AS tn ON gn.cluster_id = tn.cluster_id
           WHERE gn.value_count >= (0.2 * tn.total)
           GROUP BY gn.cluster_id
       ),
   
       subCentroids AS
       (
           SELECT
               col1 AS cluster_id,
               col4 AS some_date,
               col8 AS centroid
           FROM TableC
       ),
   
       final AS
       (
           SELECT
               sA.cluster_id AS event_id,
               sA.some_date AS event_date,
               fN.ners AS entities,
               [] AS domain_list,
               [] AS location_list,
               sB.some_title AS event_title,
               sB.smi_field[1] AS prime_src,
               sA.social_field AS social_data,
               sB.smi_field AS smi_data,
               sB.smi_count AS smi_count,
               sC.centroid
           FROM subA AS sA
           JOIN subB AS sB ON sB.cluster_id = sA.cluster_id
           JOIN subCentroids AS sC 
               ON sC.cluster_id = sA.cluster_id
               AND sC.some_date = sA.some_date
           LEFT JOIN filtered_ners AS fN 
               ON fN.cluster_id = sA.cluster_id
       )
   
   SELECT
       event_id,
       event_date,
       entities,
       domain_list,
       location_list,
       event_title,
       prime_src,
       social_data,
       smi_data,
       smi_count,
       centroid
   FROM final
   ORDER BY event_id
   
   ```
   raises
   
   
   ```
   raise SupersetSecurityException(
   superset.exceptions.SupersetSecurityException: Only `SELECT` statements are 
allowed
   ```
   
   clickhouse 24.12
   superset 4.1.1


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