Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About data_format problem such as '%%Y-%%m-%%d' in SQL editor and Visualize #4098

Closed
cherler opened this issue Dec 20, 2017 · 4 comments · Fixed by #5178
Closed

About data_format problem such as '%%Y-%%m-%%d' in SQL editor and Visualize #4098

cherler opened this issue Dec 20, 2017 · 4 comments · Fixed by #5178

Comments

@cherler
Copy link

cherler commented Dec 20, 2017

Superset version

{
"GIT_SHA": "",
"version": "0.20.6"
}

Hi:
After select my table ,then i want to visualize the result,, but i got error result to show .
I expect the x-axis is dates like 2015-03-20, 2015-03-28 in visualize web ;
but i got x-axis is %Y-%m-%d .

So i check the SQL sentence ,i found the diffrence between "sqllab query " and "visualize query" like below:

sqllab query:

SELECT date AS date,
       sum(count) AS sum__count
FROM
  (select DATE_FORMAT(FROM_UNIXTIME(tstamp-4500000000),'%%Y-%%m-%%d') as date,
          count(*) as count
   from loan_time
   group by date) AS expr_qry

GROUP BY date
ORDER BY sum__count DESC
LIMIT 50000

visualize query:

SELECT date AS date,
       sum(count) AS sum__count
FROM
  (select DATE_FORMAT(FROM_UNIXTIME(tstamp-4500000000),'%%%%Y-%%%%m-%%%%d') as date,
          count(*) as count
   from loan_time
   group by date) AS expr_qry
GROUP BY date
ORDER BY sum__count DESC
LIMIT 50000

PS:

  1. The value of col 'tstamp' is like 5894316387
  2. Cann't change sqllab query %%Y-%%m-%%d to %Y-%m-%d .because it will give me the error
    unsupported format character 'Y' (0x59) at index 116
@xrmx
Copy link
Contributor

xrmx commented Dec 20, 2017

which database is this?

@cherler
Copy link
Author

cherler commented Dec 20, 2017

the database is created by me which is using for data analysize . it does't matter
the issue is about % transferred problem with pymysql

@xrmx
Copy link
Contributor

xrmx commented Dec 20, 2017

I meant the database server :) I see it's mysql.

@mistercrunch
Copy link
Member

We recommend mysqlclient (native) over pymysql (python).

I remember spending cycles on this issue and it was pretty tricky to align across DBAPI drivers behaving in different ways. I forgot the specifics but I remember it was hard to align everything properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants