You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2020/02/25 09:52:45 UTC

[GitHub] [incubator-superset] ralphkretzschmar opened a new issue #9199: Custom mysql query with time_range in Subquery (range from filter box)

ralphkretzschmar opened a new issue #9199: Custom mysql query with time_range in Subquery (range from filter box)
URL: https://github.com/apache/incubator-superset/issues/9199
 
 
   Hello together,
   
   first of all i'm very new to superset and aswell making my first steps with mysql queries regarding BI.
   So please forgive me for my lack of knowledge and give me a hint if i could do better.
   
   If i'm wrong here, please let me know where to ask :)
   
   
   We are trying to gather certain data with  subqueries from a vtiger instance.
   But the SQL Engine transforms the query in such a case, that it doesn't get the needed data.
   
   What i try to achieve are the following steps:
   1. getting history data from a vtiger within a certain range (=time_range)
   2. sort it by date descending
   3. deduplicate by CRMID (grouped by crmid)
   
   
   
   ###  Here is the query i use to get the data:
   -----------------------
   select *
   from
           (
   select
           vtiger_modtracker_basic.crmid,
           vtiger_modtracker_basic.changedon,
           vtiger_modtracker_basic.status,        
           vtiger_modtracker_detail.fieldname,
           vtiger_modtracker_detail.prevalue,
           vtiger_modtracker_detail.postvalue,
           vtiger_potential.potentialname,
           vtiger_potential.potentialid,
           vtiger_potential.campaignname,
           vtiger_potentialscf.cf_948 AS Projectname
   from
           vtiger_modtracker_basic Inner join
           vtiger_modtracker_detail On vtiger_modtracker_detail.id = vtiger_modtracker_basic.id Inner join
           vtiger_potential On vtiger_potential.potentialid = vtiger_modtracker_basic.crmid Inner Join
           vtiger_potentialscf On vtiger_potentialscf.potentialid = vtiger_potential.potentialid
   where
           (vtiger_modtracker_basic.crmid, vtiger_modtracker_basic.changedon, vtiger_modtracker_detail.fieldname) in
                 (
                       select 	vtiger_modtracker_basic.crmid, vtiger_modtracker_basic.changedon, vtiger_modtracker_detail.fieldname
                       from  	vtiger_modtracker_basic inner join
                       vtiger_modtracker_detail On vtiger_modtracker_detail.id = vtiger_modtracker_basic.id      
                       where 	vtiger_modtracker_detail.fieldname = 'sales_stage'
                               AND vtiger_modtracker_basic.changedon  {{ time_range }}
                       group by vtiger_modtracker_basic.crmid
                 )
   order by vtiger_modtracker_basic.changedon DESC LIMIT 50000
   ) AS selection
   group by selection.crmid
   -----------------------
   
   what you expected to happen:
   1. that the "time_range" placeholder is removed by selected time_range
   2. that the query is not modified.
   
   
   ### Actual results - when i take a look at the query how it will be run
   SELECT postvalue AS postvalue,
          count(*) AS count
   FROM
     (select *
      from
        (select vtiger_modtracker_basic.crmid,
                vtiger_modtracker_basic.changedon,
                vtiger_modtracker_basic.status,
                vtiger_modtracker_detail.fieldname,
                vtiger_modtracker_detail.prevalue,
                vtiger_modtracker_detail.postvalue,
                vtiger_potential.potentialname,
                vtiger_potential.potentialid,
                vtiger_potential.campaignname,
                vtiger_potentialscf.cf_948 AS Projectname
         from vtiger_modtracker_basic
         Inner join vtiger_modtracker_detail On vtiger_modtracker_detail.id = vtiger_modtracker_basic.id
         Inner join vtiger_potential On vtiger_potential.potentialid = vtiger_modtracker_basic.crmid
         Inner Join vtiger_potentialscf On vtiger_potentialscf.potentialid = vtiger_potential.potentialid
         where (vtiger_modtracker_basic.crmid,
                vtiger_modtracker_basic.changedon,
                vtiger_modtracker_detail.fieldname) in
             (select vtiger_modtracker_basic.crmid,
                     vtiger_modtracker_basic.changedon,
                     vtiger_modtracker_detail.fieldname
              from vtiger_modtracker_basic
              inner join vtiger_modtracker_detail On vtiger_modtracker_detail.id = vtiger_modtracker_basic.id
              where vtiger_modtracker_detail.fieldname = 'sales_stage'
                AND vtiger_modtracker_basic.changedon
              group by vtiger_modtracker_basic.crmid)
         order by vtiger_modtracker_basic.changedon DESC
         LIMIT 18446744073709551610) AS selection
      group by selection.crmid) AS expr_qry
   WHERE changedon >= STR_TO_DATE('1920-02-25 00:00:00.000000', '%Y-%m-%d %H:%i:%s.%f')
   GROUP BY postvalue
   ORDER BY count DESC
   LIMIT 50000;
   
   what actually happens.
   Getting wrong data because the time range is not in the subquery anymore
   
   Thank you for your help in advance :)
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] nytai commented on issue #9199: Custom mysql query with time_range in Subquery (range from filter box)

Posted by GitBox <gi...@apache.org>.
nytai commented on issue #9199: Custom mysql query with time_range in Subquery (range from filter box)
URL: https://github.com/apache/incubator-superset/issues/9199#issuecomment-590942708
 
 
   How did you construct this query and chart? The subquerying happens when you go from sqllab -> explore. If you can compose your chart in the explore view then it shouldn’t run in a subquery. 
   
   For questions/help with superset the slack community is a better place: https://join.slack.com/t/apache-superset/shared_invite/enQtNDMxMDY5NjM4MDU0LWJmOTcxYjlhZTRhYmEyYTMzOWYxOWEwMjcwZDZiNWRiNDY2NDUwNzcwMDFhNzE1ZmMxZTZlZWY0ZTQ2MzMyNTU
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] ralphkretzschmar commented on issue #9199: Custom mysql query with time_range in Subquery (range from filter box)

Posted by GitBox <gi...@apache.org>.
ralphkretzschmar commented on issue #9199: Custom mysql query with time_range in Subquery (range from filter box)
URL: https://github.com/apache/incubator-superset/issues/9199#issuecomment-591504185
 
 
   Thank you for the hint, but i wasn't able to find a way to create a query in the explore view.
   Should i post this in slack?
   
   Best ralph

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [incubator-superset] stale[bot] commented on issue #9199: Custom mysql query with time_range in Subquery (range from filter box)

Posted by GitBox <gi...@apache.org>.
stale[bot] commented on issue #9199:
URL: https://github.com/apache/incubator-superset/issues/9199#issuecomment-619585012


   This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue `.pinned` to prevent stale bot from closing the issue.
   


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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org