Skip to content

fix(e6): gate TO_UNIX_TIMESTAMP /1000 on executor type#253

Merged
gauravdawar-e6 merged 1 commit intoe6data:mainfrom
tkaunlaky-e6:fix/e6-unix-timestamp-executor-type
Apr 23, 2026
Merged

fix(e6): gate TO_UNIX_TIMESTAMP /1000 on executor type#253
gauravdawar-e6 merged 1 commit intoe6data:mainfrom
tkaunlaky-e6:fix/e6-unix-timestamp-executor-type

Conversation

@tkaunlaky-e6
Copy link
Copy Markdown

Summary

  • Java executor returns ms so transpiled output divides TO_UNIX_TIMESTAMP(...) by 1000; native executor already returns seconds (matches Databricks) so the division was producing wrong results on NE.
  • Adds E6_EXECUTOR_TYPE env flag (default java) to pick the right behavior per deployment:
    • javaTO_UNIX_TIMESTAMP(...) / 1000
    • nativeTO_UNIX_TIMESTAMP(...)
  • Covers both the no-format branch and the PARSE_DATETIME (format) branch of to_unix_timestamp_sql.
  • Mirrors the flag at module scope in converter_api.py and adds it to the startup env-flag log line, matching the FIX_QUOTE_ESCAPES pattern.

Context

Flagged in Slack from planner logs — the transpiled query was emitting TO_UNIX_TIMESTAMP(CAST(... AS TIMESTAMP)) / 1000 + CAST(hour24 AS BIGINT) * 3600 against NE, where the first term ended up in µs-scale because NE already returns seconds. Rohit confirmed the original /1000 was added for the Java executor and a flag was needed to toggle per executor.

Test plan

  • python -m unittest tests.dialects.test_e6 — all 49 tests pass
  • New test_unix_timestamp_native_executor covers native (no-format + format branches) and java default
  • Live transpile sanity-checked with env var set/unset/native/java/NATIVE/garbage — flag is read live inside the generator method

The native executor already returns seconds (matching Databricks),
while the Java executor returns milliseconds. The transpiler
unconditionally divided by 1000, producing wrong results on NE.

Introduce E6_EXECUTOR_TYPE env flag (default: "java"):
- "java"   -> TO_UNIX_TIMESTAMP(...) / 1000
- "native" -> TO_UNIX_TIMESTAMP(...)

Applied to both the no-format and PARSE_DATETIME code paths.
Flag is also mirrored at module scope in converter_api.py for
startup logging, consistent with FIX_QUOTE_ESCAPES.
Copy link
Copy Markdown
Collaborator

@gauravdawar-e6 gauravdawar-e6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good!

@gauravdawar-e6 gauravdawar-e6 merged commit e8abaf7 into e6data:main Apr 23, 2026
6 checks passed
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