Skip to content

Reject timestampAsString override on kernel sessions - #935

Closed
jay-xiao446 wants to merge 6 commits into
mainfrom
jay/kernel-timestamp-as-string-guard
Closed

Reject timestampAsString override on kernel sessions#935
jay-xiao446 wants to merge 6 commits into
mainfrom
jay/kernel-timestamp-as-string-guard

Conversation

@jay-xiao446

Copy link
Copy Markdown
Collaborator

Summary

  • reject non-false spark.thriftserver.arrowBasedRowSet.timestampAsString in the Python kernel backend before opening a session
  • add a kernel client unit test covering the rejection path
  • add an Unreleased changelog entry

Tests

  • .venv/bin/python -m pytest tests/unit/test_kernel_client.py -q

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No issues identified by the review bot.

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: 1 Low

Looks good — the kernel _check_session_configuration faithfully mirrors Thrift's validation (same Error class and message), the check correctly runs against the stringified session_conf, and the new test asserts both rejection and that no Session is constructed. One low-severity divergence: unlike Thrift, the kernel path does not force-inject timestampAsString="false" when the config is absent.

Comment thread src/databricks/sql/backend/kernel/client.py Outdated
@jay-xiao446 jay-xiao446 added the engineer-bot Maintainer-applied gate: triggers engineer-bot (bug-fix on issue / take-over on PR). label Aug 27, 2026
@jay-xiao446
jay-xiao446 force-pushed the jay/kernel-timestamp-as-string-guard branch from 9d63ab7 to e8a375a Compare August 27, 2026 20:26

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No issues identified by the review bot.

Signed-off-by: Jay Xiao <jay.xiao@databricks.com>

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No issues identified by the review bot.

Addresses:
  - #3874674214 at src/databricks/sql/backend/kernel/client.py:331

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No issues identified by the review bot.

return sql[i:]


def _check_session_configuration(session_configuration: Dict[str, str]) -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we need this?
Thrift pass this in ExecuteStatement, I am not even sure if session can be opened if this is passed through. Does dbsql support this param at all?
[CONFIG_NOT_AVAILABLE.WITHOUT_SUGGESTION] Configuration spark.thriftserver.arrowbasedrowset.timestampasstring is not available. SQLSTATE: 42K0I

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The _check_session_configuration guard in kernel/client.py was carried over from the Thrift backend (thrift_backend.py:563) purely as a fail-fast: it rejects a user-supplied timestampAsString != false with a clear connector-side error instead of a confusing server error. Unlike Thrift, the kernel path deliberately does NOT inject timestampAsString=false (see the comment at client.py:344-353) because the kernel owns type handling natively.

Your point is valid and I can't confirm it from here: session_conf is forwarded to the kernel verbatim (client.py:328-329), so if SEA rejects this Thrift-only param entirely (the CONFIG_NOT_AVAILABLE / SQLSTATE 42K0I you cite), then even a false value would break session open, which makes the guard pointless and argues for stripping the key (or dropping the guard) rather than validating it. Confirming whether SEA accepts the param at all requires a live warehouse — the unit-only follow-up job here has no E2E credentials, so I can't verify the server behavior in this PR. Can you confirm SEA's behavior for this key? If it's rejected outright, the right fix is to strip TIMESTAMP_AS_STRING_CONFIG from session_conf before it reaches the kernel and remove the guard; I'll make that change once we've settled the intended behavior.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The Thrift one come in through ExecuteStatement and it is added by the python connector itself, but here you are guarding against OpenSession.
For kernel/SEA that flag should not matter and we should not need to guard anything about it since nobody gonna pass it on purpose.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Done. The reviewer's point had converged (the timestampAsString guard is meaningless on the kernel/SEA path — nobody passes that Thrift-only flag on purpose), so I actioned it as a code change rather than continuing the discussion:

src/databricks/sql/backend/kernel/client.py

  • Deleted _check_session_configuration and its call site in open_session
  • Removed the now-unused TIMESTAMP_AS_STRING_CONFIG constant and Error import
  • Left a comment noting session_conf is forwarded to the kernel verbatim, with no injection or validation of the Thrift-only flag

tests/unit/test_kernel_client.py

  • Removed the three guard tests, added one asserting the conf is forwarded verbatim, dropped the unused Error import

All 127 tests in tests/unit/test_kernel_client.py pass (run wi

Pushed acbe571.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

good catch, thanks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NEEDS HUMAN DECISION — the bots can't resolve this thread; a maintainer's input is required.

Thread has converged: the requested change was already applied and pushed in commit acbe571 (removed _check_session_configuration, its call site, and the unused TIMESTAMP_AS_STRING_CONFIG constant — confirmed absent from client.py just now), and the reviewer's last message ("good catch, thanks") is a closing acknowledgment. Nothing further is actionable in this PR; no code change or reply is warranted.

Addresses:
  - #3876101905 at src/databricks/sql/backend/kernel/client.py:105

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: 1 High

Blocking mismatch: the PR title, description, and changelog all claim the kernel path now rejects a non-false timestampAsString "matching the Thrift backend's validation," but the diff (comment + new test) implements and asserts the opposite — verbatim forwarding with no rejection. The code itself is internally consistent; the documentation/PR metadata is wrong. Align title/description/changelog with the actual behavior (or implement the rejection the title promises). See F1.

Comment thread CHANGELOG.md Outdated
Addresses:
  - #3876213902 at CHANGELOG.md:4

Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>

@peco-review-bot peco-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No issues identified by the review bot.

@eric-wang-1990

Copy link
Copy Markdown
Contributor

There is no meaningful code changes in this PR I think we can just close it @jay-xiao446

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engineer-bot Maintainer-applied gate: triggers engineer-bot (bug-fix on issue / take-over on PR).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants