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

[BUG] Incorrect Timestamp Displayed in Tableau Desktop & Tableau Prep from OpenSearch Database #128

Open
thomasLoveJesus opened this issue Jan 10, 2025 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@thomasLoveJesus
Copy link

thomasLoveJesus commented Jan 10, 2025

What is the bug?
Incorrect Timestamp Displayed in Tableau Desktop & Tableau Prep from OpenSearch Database.
When we load data into Tableau Desktop or Tableau Prep, the timestamp field incorrectly display the year as 1970. However, the actual timestamp in the OpenSearch JSON is correctly recorded as 2025.

How can one reproduce the bug?
Steps to reproduce the behavior:

  1. Please refer to the attached figures.
  2. Install the required .taco and drivers for opensearch and Tableau Desktop to communicate.
  3. Open Tableau Desktop and connect OpenSearch by OpenSearch Project
  4. After reading the data, preview one of the tables containing timestamp
  5. One can see the wrong year 1970, should be 2025

What is the expected behavior?
The timestamp should match the data in OpenSearch (2025) and not default to 1970 in Tableau Desktop and Tableau Prep.

What is your host/environment?

  • OS: Linux CentOS 7.9 for OpenSearch
  • OpenSearch by OpenSearch Project version: 1.3.19
  • Connectors for opensearch and Tableau Desktop:
  • opensearch_sql_jdbc.taco
  • opensearch_sql_jdbc-v1.0.1.taco
  • opensearch_sql_jdbc-1.1.0.1.jar
  • Tableau Desktop Professional Edition 2024.3.2 (20243.24.1211.0901) Windows version
  • Tableau Prep Builder 2024.3 (24.32.24.1209.1136) Windows version

Do you have any screenshots?
Install the required .taco and drivers for opensearch and Tableau Desktop to communicate:
opensearchInstallationGuide

Required .taco files
1

Required .jar file
2

OpenSearch Dashboard showing the original timestamp (which is the correct year 2025):
OpenSearch Dashboard showing the original timestamp

Connect OpenSearch to Tableau:
Connect OpenSearch to Tableau

timestamp in Tableau Desktop showing the wrong year 1970, should be 2025:
Fig 1
Fig 2

Do you have any additional context?
Add any other context about the problem.

@thomasLoveJesus thomasLoveJesus added bug Something isn't working untriaged labels Jan 10, 2025
@thomasLoveJesus thomasLoveJesus changed the title [BUG] [BUG]Incorrect Timestamp Displayed in Tableau Desktop & Tableau Prep from OpenSearch Database Jan 10, 2025
@thomasLoveJesus thomasLoveJesus changed the title [BUG]Incorrect Timestamp Displayed in Tableau Desktop & Tableau Prep from OpenSearch Database [BUG] Incorrect Timestamp Displayed in Tableau Desktop & Tableau Prep from OpenSearch Database Jan 10, 2025
@Swiddis Swiddis added good first issue Good for newcomers and removed untriaged labels Jan 14, 2025
@Swiddis
Copy link
Collaborator

Swiddis commented Jan 14, 2025

The problem seems to be a unit mismatch somewhere between OpenSearch and Tableau (either OS -> JDBC or JDBC -> Tableau). In particular, 1736477400 is the timestamp for 2025/01/10 @ 2:50:00 AM as epoch seconds. However, if you read those seconds as milliseconds, you get 1970/01/21 @ 2:21:17 AM (i.e. the same as the epoch 1736477.4 seconds).

Looking over the code to check whether it's the first or the second part, we can see that the culprit is TimestampType.fromValue indirectly passing to the java.sql.Timestamp constructor, which expects milliseconds. To fix the bug, we should add logic to check the magnitude of the timestamps and convert from seconds to milliseconds if necessary.

As a workaround, ensure timestamps are stored as milliseconds instead of seconds.

Marking as good first issue for external contributors.

@thomasLoveJesus
Copy link
Author

Hi Swiddis,

Thank you for the workaround suggestion. We created another field in OpenSearch called timestamp_second and let Tableau consume it instead of the default timestamp field. I have found out that when Tableau reads a timestamp, it will cast it into a Date and time data type. However, if we feed Tableau timestamp_second, since Tableau treats it as a Number, I can use the formula provided by Tableau, DATEADD('second', [timestamp_second], #1970-01-01#), to display the intended Date and Time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants