{"action":"created","issue":{"url":"https://api.github.com/repos/airbnb/caravel/issues/274","repository_url":"https://api.github.com/repos/airbnb/caravel","labels_url":"https://api.github.com/repos/airbnb/caravel/issues/274/labels{/name}","comments_url":"https://api.github.com/repos/airbnb/caravel/issues/274/comments","events_url":"https://api.github.com/repos/airbnb/caravel/issues/274/events","html_url":"https://github.com/airbnb/caravel/issues/274","id":146096357,"number":274,"title":"Sql Metric Expression which uses % has % duped in tableView query","user":{"login":"scophotog","id":1374972,"avatar_url":"https://avatars.githubusercontent.com/u/1374972?v=3","gravatar_id":"","url":"https://api.github.com/users/scophotog","html_url":"https://github.com/scophotog","followers_url":"https://api.github.com/users/scophotog/followers","following_url":"https://api.github.com/users/scophotog/following{/other_user}","gists_url":"https://api.github.com/users/scophotog/gists{/gist_id}","starred_url":"https://api.github.com/users/scophotog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scophotog/subscriptions","organizations_url":"https://api.github.com/users/scophotog/orgs","repos_url":"https://api.github.com/users/scophotog/repos","events_url":"https://api.github.com/users/scophotog/events{/privacy}","received_events_url":"https://api.github.com/users/scophotog/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-05T20:07:11Z","updated_at":"2016-04-07T01:15:24Z","closed_at":null,"body":"I created a sql metric with the expression:\r\n\r\n    CAST(strftime(\"%s\", max(\"timestamp\")) AS INT)\r\n\r\nWhen I used this metric to create a table view the values were not being populated. Looking into the JSON I found the query had duplicated the `%`:\r\n\r\n```\r\nquery: \"SELECT \"serviceName\" AS \"serviceName\", CAST(strftime(\"%%s\", max(\"timestamp\")) AS INT)\r\n AS latest_date FROM \"testResults\" WHERE timestamp >= '2016-03-29 15:57:43.000000' AND timestamp <= '2016-04-05 15:57:43.000000' GROUP BY \"serviceName\" ORDER BY \r\nCAST(strftime(\"%%s\", max(\"timestamp\")) AS INT) DESC LIMIT 50000 OFFSET 0\"\r\n```\r\n\r\nCurrent end result is this column ends up displaying a 0 for each entry"},"comment":{"url":"https://api.github.com/repos/airbnb/caravel/issues/comments/206641898","html_url":"https://github.com/airbnb/caravel/issues/274#issuecomment-206641898","issue_url":"https://api.github.com/repos/airbnb/caravel/issues/274","id":206641898,"user":{"login":"mistercrunch","id":487433,"avatar_url":"https://avatars.githubusercontent.com/u/487433?v=3","gravatar_id":"","url":"https://api.github.com/users/mistercrunch","html_url":"https://github.com/mistercrunch","followers_url":"https://api.github.com/users/mistercrunch/followers","following_url":"https://api.github.com/users/mistercrunch/following{/other_user}","gists_url":"https://api.github.com/users/mistercrunch/gists{/gist_id}","starred_url":"https://api.github.com/users/mistercrunch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mistercrunch/subscriptions","organizations_url":"https://api.github.com/users/mistercrunch/orgs","repos_url":"https://api.github.com/users/mistercrunch/repos","events_url":"https://api.github.com/users/mistercrunch/events{/privacy}","received_events_url":"https://api.github.com/users/mistercrunch/received_events","type":"User","site_admin":false},"created_at":"2016-04-07T01:15:24Z","updated_at":"2016-04-07T01:15:24Z","body":"Have you tried doubling the `%` as in `%%`? I think we had this bug before but forgot about the details/workaround."}}