4 Replies Latest reply on Feb 14, 2016 11:46 AM by Oscar Morante

    Grouping by week generates bad SQL?

    Oscar Morante

      Hi,

      I'm new to Tableau and I'm doing some testing with Apache Drill.  I'm trying to group some data by week but when I do so Tableau queries the database with SQL that has syntax errors like this:

       

      SELECT * FROM (SELECT AS `wk_purchase_time_ok`
      FROM `tvmetrix.metrix`.`vodpurchases` `vodpurchases`) T LIMIT 0
      

       

      Notice how there's nothing left of "AS `wk_purchase_time_ok`".  If I switch from "Week number" or "Weekday" to let's say "Month" then the query that get's to Drill is correct:

       

      SELECT CAST(EXTRACT(MONTH FROM `vodpurchases`.`purchase_time`) AS INTEGER) AS `mn_purchase_time_ok`
      FROM `tvmetrix.metrix`.`vodpurchases` `vodpurchases`
      GROUP BY CAST(EXTRACT(MONTH FROM `vodpurchases`.`purchase_time`) AS INTEGER)
      

       

      Any idea what might be going on?

      Thanks,