-
Notifications
You must be signed in to change notification settings - Fork 63
fix(kernel): Thrift parity fixes (TIMESTAMP range, DDL rows, User-Agent, VOID type) #416
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
Open
mani-mathur-arch
wants to merge
5
commits into
main
Choose a base branch
from
mani/sea-kernel-comparator-fixes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
465c68c
fix(kernel): render out-of-nanosecond-range TIMESTAMPs without wrapping
mani-mathur-arch 21ad6fa
fix(kernel): report 0 affected rows for DDL to match Thrift
mani-mathur-arch c077271
fix(kernel): forward User-Agent so query history attributes the Go dr…
mani-mathur-arch 8815db9
fix(kernel): report VOID/NULL columns as STRING to match Thrift
mani-mathur-arch 0163bcd
test(kernel): cover UA forwarding + VOID column-type parity
mani-mathur-arch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package kernel | ||
|
|
||
| // This file is intentionally NOT behind the `cgo && databricks_kernel` build tag. | ||
| // It holds the pure normalization of the C ABI's affected-row count so the rule is | ||
| // unit-testable in the default CGO_ENABLED=0 build (like paramBindArg in bindparams.go), | ||
| // separate from the cgo call site in operation.go. | ||
|
|
||
| // normalizeAffectedRows maps the kernel C ABI's modified-row count onto the value | ||
| // database/sql's Result.RowsAffected() reports, matching the Thrift path. | ||
| // | ||
| // The C ABI returns -1 for "not applicable / unknown": DDL, SELECT, or a warehouse | ||
| // that doesn't surface the counter (the kernel's num_modified_rows Option<i64> is | ||
| // None). The Thrift path reports 0 in exactly those cases (TGetOperationStatusResp | ||
| // defaults NumModifiedRows to 0), so the -1 sentinel is folded to 0 for parity. | ||
| // A real DML count (>= 0) passes through unchanged. | ||
| func normalizeAffectedRows(n int64) int64 { | ||
| if n < 0 { | ||
| return 0 | ||
| } | ||
| return n | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package kernel | ||
|
|
||
| import "testing" | ||
|
|
||
| func TestNormalizeAffectedRows(t *testing.T) { | ||
| cases := []struct { | ||
| name string | ||
| in int64 | ||
| want int64 | ||
| }{ | ||
| {"ddl or select sentinel (-1) folds to Thrift's 0", -1, 0}, | ||
| {"any negative folds to 0", -42, 0}, | ||
| {"zero real count is preserved", 0, 0}, | ||
| {"positive DML count passes through", 7, 7}, | ||
| {"large DML count passes through", 1_000_000, 1_000_000}, | ||
| } | ||
| for _, tc := range cases { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| if got := normalizeAffectedRows(tc.in); got != tc.want { | ||
| t.Errorf("normalizeAffectedRows(%d) = %d, want %d", tc.in, got, tc.want) | ||
| } | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,6 +132,20 @@ func (k *KernelBackend) OpenSession(ctx context.Context) error { | |
| return err | ||
| } | ||
|
|
||
| // User-Agent so query history attributes the kernel path to this driver. | ||
| if k.cfg.UserAgent != "" { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please verify from query history |
||
| name := newCStr("User-Agent") | ||
| val := newCStr(k.cfg.UserAgent) | ||
| errSet := call(func() C.KernelStatusCode { | ||
| return C.kernel_session_config_set_custom_header(cfg, name.c, val.c) | ||
| }) | ||
| name.free() | ||
| val.free() | ||
| if errSet != nil { | ||
| return fmt.Errorf("kernel: set_custom_header[User-Agent]: %w", toConnError(errSet)) | ||
| } | ||
| } | ||
|
|
||
| // TLS: crypto/tls's InsecureSkipVerify accepts any server cert, so relax both | ||
| // chain validation and the hostname check — mapping only one would leave the | ||
| // kernel path stricter than the Thrift path it mirrors (a self-signed cert | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make this change in kernel not here