Skip to content

Conversation

ZhitongYan
Copy link

Issue #, if available:
N/A (or add issue number if there's a related GitHub issue)

Description of changes:
Fix timezone handling in Snowflake connector timestamp formatting for WHERE clauses

Problem:
The SnowflakeQueryStringBuilder was not respecting timezone information when formatting timestamps for SQL WHERE clauses. This could lead to incorrect query results when timestamp data includes timezone information, as the formatter would use the system default timezone instead of the data's actual timezone.

Solution:

  • Extract timezone information from ArrowType.Timestamp objects
  • Default to "UTC" when timezone is null or empty
  • Apply the correct timezone to SimpleDateFormat before formatting timestamps

Changes:

  • Modified getObjectForWhereClause() method in SnowflakeQueryStringBuilder.java to handle timezone-aware timestamp formatting
  • Added comprehensive test cases covering:
    • Timestamps with null timezone (defaults to UTC)
    • Timestamps with explicit UTC timezone
    • Timestamps with various timezone formats (PST, America/Los_Angeles, GMT-8:00)

Testing:
Added unit tests to verify correct timestamp formatting across different timezone scenarios, ensuring the formatted timestamps reflect the proper timezone conversion.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

⏳ I'm reviewing this pull request for security vulnerabilities and code quality issues. I'll provide an update when I'm done

1 similar comment
Copy link

⏳ I'm reviewing this pull request for security vulnerabilities and code quality issues. I'll provide an update when I'm done

Copy link

✅ I finished the code review, and didn't find any security or code quality issues.

1 similar comment
Copy link

✅ I finished the code review, and didn't find any security or code quality issues.

@burhan94
Copy link
Collaborator

Hi

Thank you for the contribution. We're you able to test this via Athena?

@burhan94
Copy link
Collaborator

Requested a member of the Trianz team to also test this out.

@burhan94
Copy link
Collaborator

Hi,

can you provide a repro of how to trigger this issue from Athena? Trianz team was not able to hit this codepath at all.

@burhan94
Copy link
Collaborator

burhan94 commented Oct 6, 2025

Hi @ZhitongYan can you pls take a look at my question above?

@burhan94 burhan94 self-assigned this Oct 6, 2025
@ZhitongYan
Copy link
Author

I did not tested in Athena Console, but was running unit tests in my fresh workspace with system default timezone which led to the unit tests failures.

@burhan94
Copy link
Collaborator

burhan94 commented Oct 9, 2025

closing in favor of: #2997

@burhan94 burhan94 closed this Oct 9, 2025
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 this pull request may close these issues.

2 participants