ClickHouse / clickhouse-tableau-connector-jdbc

Tableau connector to ClickHouse using JDBC driver
Apache License 2.0
57 stars 9 forks source link

Incorrect return of Datepart function #43

Closed vlauzeckas closed 1 year ago

vlauzeckas commented 1 year ago

hi, we have issues while running "datepart" function. I found in your code such line:

<formula part='weekday'>toDayOfWeek(%2) mod 7 + 1</formula>

Why do you add this 7+1?

I have tried to run this directly on clickhouse: select toDayOfWeek( toDate('2022-12-19')) mod 7 + 1

And it returns 2 where December 19 is Monday.

yurifal commented 1 year ago

Hi @vlauzeckas

Tableau interprets 1 as Sunday (hence 2 as Monday) etc.

vlauzeckas commented 1 year ago

as i understand it is configurable on data source level in tableau: image

currently if i configure that my week starts on Monday i get wrong results

yurifal commented 1 year ago

Could you please explain what the "wrong results" are?

yurifal commented 1 year ago

@vlauzeckas fyi: both DATEPART('weekday', #2022-12-19#) and DATEPART('weekday', #2022-12-19#, 'monday') do always return 2.

vlauzeckas commented 1 year ago

ghmm, actually you are right. i have tested with postgresl and it behaves similarly